GithubHelp home page GithubHelp logo

Comments (8)

mattbryson avatar mattbryson commented on May 1, 2024 4

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');

http://jsfiddle.net/PDdn3/2/

from bootstrap-select.

NKCSS avatar NKCSS commented on May 1, 2024

This would be nice to have

from bootstrap-select.

mattbryson avatar mattbryson commented on May 1, 2024

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.

caseyjhol avatar caseyjhol commented on May 1, 2024

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.

mattbryson avatar mattbryson commented on May 1, 2024

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.

fvera avatar fvera commented on May 1, 2024

Not support disabled attribute, but YES support readonly attribute, then...

$("[id^=yourselector]").prop("readonly", "");

from bootstrap-select.

saptisunil avatar saptisunil commented on May 1, 2024

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.

jeuelc avatar jeuelc commented on May 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.