Search code examples
javascriptjqueryjquery-uijquery-pluginsmulti-select

How can I make the jQuery MultiSelect widget read-only?


How can I make Eric Hynds' MultiSelect plugin for jQuery UI read-only? I know how to disable the widget, but I would like to display its contents without the user being able to change anything.


Solution

  • SEE THIS FIDDLE

    basically, just pass a class you can target to the multiselect when you create it, then using that targeted class set disabled to true on all the inputs within the wrapper.

    $("#jquery_fun").multiselect({classes:'jquery_fun'});
    $('.jquery_fun').find('input').each(function(){
        $(this).prop('disabled', true);
    });