Comments (8)
There is using JQ and the plugin.
First disable the option with jQuery, and then call render
on the plugin.
$('#mySelect option[value="3"]').prop('disabled', true);
$('#mySelect').selectpicker('render');
from bootstrap-select.
This would be nice to have
from bootstrap-select.
but we could simplify this with one call, something like
$('#mySelect').selectpicker('disable', selector);
We could pass the selector as either a straight value, or array of values...
3
or my value
or [1,5,10]
and it could also be a JQ Selector..
[value="3"]
or #myID
or .MyClass
so something like
$('#mySelect').selectpicker('disable', [1,3,'hello']);
$('#mySelect').selectpicker('disable', '[value="3"]');
$('#mySelect').selectpicker('disable', '.MyOptionClass');
?
from bootstrap-select.
We could add it in there...but I think it would just be simpler to just run render
again. It seems like it would be less documentation to have to remember - simply add your typical line of jQuery to disable the option and then include $('.selectpicker').selectpicker('render');
right after it. What do others think?
from bootstrap-select.
It is more flexible leaving it down to the dev to update the data and then re-render. Im inclined to leave it as is.
from bootstrap-select.
Not support disabled attribute, but YES support readonly attribute, then...
$("[id^=yourselector]").prop("readonly", "");
from bootstrap-select.
Heyy ! I just want to disable some of the options from the drop down list. How can i do that? Please help ! Thanks in Advance
from bootstrap-select.
any of the following will work:
$("#selectId option[value=1]").attr("disabled","disabled");
$("#selectId option[value='2']").attr("disabled","disabled");
$("#selectId option[value=3]").prop("disabled",true);
$("#selectId option[value='4']").prop("disabled",true);
just refresh the rendering of the selectpicker:
$('#selectId').selectpicker('refresh');
from bootstrap-select.
Related Issues (20)
- Select with icon HOT 4
- Button onclick not working in latest version, worked fine in 1.12.4
- [email protected] not working with Bootstrap 5.3.2 HOT 4
- data-selected-text-format after render or refresh
- ADA improvements for Select/deselect all options
- Name of Ukrainian language file is wrong.
- Select does not display in dropdown-menu HOT 1
- is there any feature like select all HOT 1
- Unable to have noneSelectedText with HTML with latest version
- doneButtonText not in i18n files and no longer adjustable via Javascript defaults
- SweetAlert2 - bootstrap select dropdown appears behind/cutoff parent div border HOT 1
- Error when have a class attribute for optgroup tag
- wrong preview for > in <select class="form-control mobileSelect"> in Safari
- Turkish Case Sensitive
- I want to style the top div and add margin to it, unable to do so HOT 1
- Show as a list instead of dropdown
- Show selected items first in the drop down list
- keyCode isn't propagated in the event
- Bootstrap Floating labels broken HOT 9
- XSS injection possible with data-content HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootstrap-select.