erichynds

Hi, I'm Eric Hynds, a front-end website developer living outside of Boston, Massachusetts. I'm passionate about developing functional, standard-compliant, and user-friendly websites.

jQuery UI MultiSelect Widget

This is the successor and port of my original jQuery MultiSelect Plugin to a jQuery UI widget. While both will actively be maintained, I highly recommend you use this version over the plugin version. It has a more robust feature set, is faster, and is much more flexible. MultiSelect turns an ordinary HTML select control into an elegant drop down list of checkboxes with themeroller support.

This version inherits all the benefits from the jQuery UI widget factory that are not available in the plugin version. The most requested feature was the ability to call methods on instances after initialization (e.g., statefullness), and now there are 10 to choose from! Also present are eight events you can bind to, which in the previous version, had fewer and limited support. Finally, there is support for effects. Just include the jQuery UI effects dependency and specify the name of the opening or closing effect to use (and speed, if you wish!)

Demo

See what you’re missing out on? Many more demos are available here.

$("#multiselect-demo").multiselect({
   selectedText: "# of # selected"
});

Advanced usage using optgroups and the filtering extension:

$("#multiselect-demo")
   .multiselect({
      noneSelectedText: 'Select car/boat manufacturers'
      selectedList: 4
   })
   .multiselectfilter();

Usage

Using this widget is simple. First, include the following files:

  • jQuery 1.4.2+
  • jQuery UI 1.8 widget factory and effects (if you’d like to use them)
  • A jQuery UI theme
  • This widget: jquery.multiselect.js
  • The CSS file: jquery.multiselect.css

Next construct a standard multiple select box. Do not forget the multiple attribute:

<select id="example" name="example" multiple="multiple">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>

Finally, initialize the widget on the select box once the document is ready:

$(document).ready(function(){
   $("#example").multiselect();
});

See the demos for advanced usages and for more documentation!

Options

To further customize multiselect, pass in a object with one or more of the options below.

// example:
$("select").multiselect({
   header: "Choose an Option!"
});
Option Description Default
header Either a boolean value denoting whether or not to display the header, or a string value. If you pass a string, the default “check all”, “uncheck all”, and “close” links will be replaced with the specified text. true
height Height of the checkbox container (scroll area) in pixels. If set to “auto”, the height will calculate based on the number of checkboxes in the menu. 175
minWidth Minimum width of the entire widget in pixels. Setting to “auto” will disable. 225
checkAllText The text of the “check all” link. Check all
uncheckAllText The text of the “uncheck all” link. Uncheck All
noneSelectedText The default text the select box when no options have been selected. Select options
selectedText The text to display in the select box when options are selected (if selectedList is false). A pound sign (#) will automatically replaced by the number of checkboxes selected. If two pound signs are present in this parameter, the second will be replaced by the total number of checkboxes available. Example: "# of # checked".

This parameter also accepts an anonymous function with three arguments: the number of checkboxes checked, the total number of checkboxes, and an array of the checked checkbox DOM elements. See examples for usage.

# selected
selectedList A numeric (or boolean to disable) value denoting whether or not to display the checked opens in a list, and how many. A number greater than 0 denotes the maximum number of list items to display before switching over to the selectedText parameter. A value of 0 or false is disabled. false
show The name of the effect to use when the menu opens. To control the speed as well, pass in an array: ['slide', 500] empty string
hide The name of the effect to use when the menu closes. To control the speed as well, pass in an array: ['explode', 500] empty string
autoOpen A boolean value denoting whether or not to automatically open the menu when the widget is initialized. false
multiple If set to false, the widget will use radio buttons instead of checkboxes, forcing users to select only one option. true
classes
New in 1.5!

Additional class(es) to apply to BOTH the button and menu for further customization. Separate multiple classes
with a space. You’ll need to scope your CSS to differentiate between the button/menu:

/* button */
.ui-multiselect.myClass {}
 
/* menu */
.ui-multiselect-menu.myClass {}
empty string
position
New in 1.5! Requires jQuery 1.4.3+, jQuery UI position utility

This option allows you to position the menu anywhere you’d like relative to the button; centered, above, below (default), etc. Also provides collision detection to flip the menu above the button when near the bottom of the window. If you do not set this option or if the position utility has not been included, the menu will open below the button.

Requires the jQuery UI position utility and jQuery 1.4.3+. Please see this demo for usage instructions.

empty object

Events

Hook into any of the events below by either binding to the event name, or passing in the name of the event during initialization:

// bind to event
$("#multiselect").bind("multiselectopen", function(event, ui){
	// event handler here
});
 
// or pass in the handler during initialization
$("#multiselect").multiselect({
	open: function(event, ui){
		// event handler here
	}
});
Event Description
create
Requires jQuery UI Widget Factory 1.8.6+

Fires when the widget is created for the first time.

beforeopen Fires right before the menu opens. Prevent the menu from opening by returning false in the handler.
open Fires after the widget opens.
beforeclose Fires right before the menu closes. Prevent the menu from closing by returning false in the handler.
close Fires after the widget closes.
checkAll Fires when all the options are checked by either clicking the “check all” link in the header, or when the “checkall” method is programatically called (see next section).
uncheckAll Fires when all the options are all unchecked by either clicking the “uncheck all” link in the header, or when the “uncheckall” method is programatically called (see next section).
optgrouptoggle Fires when an optgroup label is clicked on. This event receives the original event object as the first argument, and a hash of values as the second argument:

$("#multiselect").bind("multiselectoptgrouptoggle", function(event, ui){
	/*
	event: the original event object, most likely "click"
 
	ui.inputs: an array of the checkboxes (DOM elements)
        inside the optgroup
 
        ui.label: the text of the optgroup
 
        ui.checked: whether or not the checkboxes were
        checked or unchecked in the toggle (boolean)
	*/
});
click Fires when a checkbox is checked or unchecked.

$("#multiselect").bind("multiselectclick", function(event, ui){
	/*
	event: the original event object
 
	ui.value: value of the checkbox
	ui.text: text of the checkbox
	ui.checked: whether or not the input was checked
        or unchecked (boolean)
	*/
});

Methods

After an instance has been initialized, interact with it by calling any of these methods:

// example:
$("#multiselect").multiselect("method_name");
Method Description
open Opens the menu.
close Closes the menu.
refresh
New in 1.8!

Reloads the checkbox menu. If you’re dynamically adding/removing option tags on the original select via AJAX or DOM manipulation methods, call refresh to reflect the changes in the widget.

disable Disable the entire widget.
enable Enable the entire widget.
checkAll Check all checkboxes.
uncheckAll Uncheck all checkboxes.
isOpen Returns a boolean denoting if the widget is currently open or not.
getChecked Returns an array of all the checked checkboxes.
widget Returns the menu container (all checkboxes inside).
option Set or get one of the options after the widget has been initialized. If changing an option, the new option setting will take affect immediately.
destroy Destroy the widget, and revert back to the original select box.

Filter Plugin

A filtering widget is available which, once initialized on a multiselect instance, will insert a text box inside the widget header. Typing in the input will filter rows and return matches in real time. To view a demo, download, or read the documentation, head to the demo page.

How do I…?

These questions came out of the comments which others will probably find useful:

Set default options for all multiselect instances?

The options object is located in $.ech.multiselect.prototype.options. To configure options that all new instances will inherit, it’s easier to set them in this object instead of on an instance-by-instance basis.

$.ech.multiselect.prototype.options.selectedText = "# of # selected";

Retrieve all selected values?

The easiest way is to call val() on the select box:

var values = $("select").val();

The same can be accomplished using the multiselect API. Call the getChecked method and map a new array:

var array_of_checked_values = $("select").multiselect("getChecked").map(function(){
   return this.value;	
}).get();

Retrieve values on the server?

Depends on your server-side language. In PHP et. al., you may need to name your select with square brackets on the end so the values can be captured as an array. I will probably wind up implementing this as an option at some point so it’ll degrade a bit better.

Prevent the selectedList option from increasing the button’s height?

Open up the CSS file and edit the .ui-multiselect declaration.

.ui-multiselect { height:25px; overflow-x:hidden; padding:2px 0 2px 4px; text-align:left }

The height you’ll need to set depends on the font size and padding you use, so it may need adjusting.

Manually check or uncheck a checkbox?

The checkboxes can be accessed after calling the "widget" method. Simply manually trigger the NATIVE click event on them:

// manually check (or uncheck) the third checkbox in the menu:
$("select").multiselect("widget").find(":checkbox").each(function(){
   this.click();
});

The native click event must be used (trigger('click') will not work) due to this bug in jQuery’s core.

All necessary events and actions, like updating the button value, will automatically fire.

Alternatively, you could give the original option tag the selected attribute, and then call MultiSelect’s refresh method.

Show checked values on another part of my page?

Use multiselect in conjunction with the validate plugin?

Make sure you’re using version 1.7 of the validation plugin; 1.6 is NOT supported with either this plugin or jQuery version 1.4.2+. Validate 1.6 defines its own “delegate” method which conflicts with the method added in jQuery. The conflict was resolved in Validate 1.7.

Issues

If you find any issues, please report them using the GitHub issue tracker. Thanks!

Related posts:

  1. jQuery MultiSelect Plugin w/ ThemeRoller Support
  2. Using $.widget.bridge Outside of the Widget Factory
  3. A jQuery UI Growl/Ubuntu-like Notification Widget
  4. Tips for Developing jQuery UI 1.8 Widgets

Tags: , ,

  • http://blog.pengoworks.com/ Dan G. Switzer, II

    Definitely looking good, but keyboard support should be the next priority. In our research, we've found that a large number of application users still prefer to use the keyboard for input. Being able to arrow through and use the space bar to select/unselect options would go a long way to improving the UI.

  • http://biacreations.com Jim Geurts

    Clicking the down arrow in Chrome opens & immediately closes the dropdown menu. Minor bug, but otherwise it looks good

  • ehynds

    What version are you testing in? I'm unable to reproduce this in 6.0.453.1 dev (linux) or 5.0.375.99 (windows)

  • http://biacreations.com Jim Geurts

    5.0.375.86 on Windows 7. The behavior looks as though the down arrow icon and the textbox are both calling toggle, for the drop down menu, at the same time.

  • ehynds

    I see it now – thanks. Fixed: http://github.com/ehynds/jquery-ui-multiselect-…

    Will be releasing 1.3 soon with this included.

  • http://twitter.com/taciomedeiros Tacio Medeiros

    Wow, great improvement! This new version couldn't come in better time. The destroy method really make it easier now for me to dynamically make copies of the multiselect. The getChecked too will be handy.

    Thanks again.

    (It's Refactoring time!)

  • ehynds

    I wrote a filtering plugin for this widget tonight, available for testing here:

    http://www.erichynds.com/examples/jquery-ui-mul…

    It's definitely still in alpha as I've barely tested it and I'm sure there are a lot of logistics to pan out. Feedback is encouraged!

  • Daniel Schmid

    I havee 3 select boxes in a vertical alingment

    1) with all having autoOpen=true. Only last selectbox opens on load, the first and second are closed.
    2) I like to have them all open and arrange the vertical position automatically accordning to the height of opening dropdown menu. Now the header is fixed and when one dropdown menu opens, it covers the one below.

  • Wallenium

    hey folks. is it possible to get the selected names instead of “1 of 30 selected”?

    http://dropdown-check-list.googlecode.com/svn/t…

    as seen here.. would love to use this widget, cause its faster.. but need the selected names

  • ehynds

    Take a look at the “selectedList” option, or the demo showing you how to pass a function to selectedText.

  • http://twitter.com/taciomedeiros Tacio Medeiros

    Hey,

    in the methods table of the documentation above you wrote “checkall” and “uncheckall” instead of “checkAll” and “uncheckAll”. It seems these methods only work if written camelCase.

  • Wallenium

    yeah. got it. thx a lot.
    any plans on integrating this into the UI? would be cool? maybe the author wanna talk to the ui team ;)

  • ehynds

    Good catch – fixed. Thanks

  • http://www.google.com/profiles/112292541245588274665 Nino

    The first initialisation works, the selected items in the html select are getting selected in the multiselect.

    After a refresh I still have my multiselect, but none of the items are selected.

  • Lucian Jp

    $.fn.multiSelect.defaults.XXXXXXXXXXXXX
    doesn't work on that version from previous implementation.

  • Greg Saunders

    Great widget but I need help. It seems that if i use this in a form the select field never makes it into the POST of the http request. Am I missing something?

  • Barry

    how do you access the getChecked array?

  • PT

    Again nice job! I have two things for you.

    Does this version support Overriding Options?

    Also here's a bug I've encountered. In IE6 & IE7 when I have more than 107 items selected the multiselect fails to submit the form without any type of error message indications. FF3 and IE8 work.

  • ehynds

    it's now $.ech.multiselect.prototype.options;

  • ehynds

    what's your server-side language? you may need to add brackets to the end of your select name.. I will probably add an option for this in a future release.

  • ehynds

    var array_of_selected_boxes = $(“select”).multiselect(“getChecked”);

  • ehynds

    What do you mean by overriding options? You can set them once globally under the $.ech.multiselect.prototype.options namespace, individually by passing an object when you init the multiselect, or use the setOption method.

    I'll check into that bug; thanks for the report.

  • PT

    By overriding options I meant the default options.
    Where the plugin was: $.fn.multiSelect.defaults.minWidth = 500;
    The widget is now : $.ech.multiselect.prototype.options.minWidth = 500;
    You might want to document that change under the Options section.

    Also I dont see the setOption method listed above in the Methods list.

    Thanks!

  • PT

    Another question on Options.

    Has the “position” option been removed from the widget? I found it useful for a long multiselect list that is at the bottom of a page. I set it to “middle” or “top” depending on the list size so the user didnt have to scroll down the page any more than necessary. (Note: I also customized the widget to display the title of the multiselect in the header so the user knows what control they are modifying. This was especially useful when the position was set to “middle”.)

    Thanks!

  • Tillclaes

    Hi, I've been contemplating to use your very neat multiselect plugin. However, I've been having some problems. Today I tried the Single Select in IE8 and I can select multipe radio buttons (which is being reflected in the selectedText as well).

    I've also had some bad luck with using it in my existing app, my other jQuery script stopped working. Do you think I'm just having a bad day / bad luck or should is your srcipt a bit too early in the release cycle to be used in production? Will it work in IE7?

    Sorry for being a bit vague about my experience, but I'm not at work and I think my kid is going to wake up soon ;-) I do believe your plugin looks great and I hope to use it for both multi select and single select, because I want to keep my plugins to a minimum (alternative would be to include Filament Groups single select, but if I can avoid it I think it would be better for maintenance).

    Right now I'm using asmSelect and Stylish Select, but been having problems with newer versions of jQuery and jQuery UI. And since we're already using UI I hope this to be a more unified solution. It is a jQuery djungle out there :-)

    Any advice is appreciated.

    Thanks,
    Claes

  • ehynds

    yes – I am attempting to move that logic to the jQuery UI position utility, which will allow the menu to automatically flip if it's near the end of the page. I'm finding it to be quite buggy, however.

  • ehynds

    Claes, there shouldn't be any conflicts unless one of your other plugins is also named multiselect. Also make sure you're using jQuery 1.4.2 and jQuery UI 1.8. I will look into that single select bug.. what have you named your select? Can you inspect the radio buttons with firebug and see if their names are different?

  • Tillclaes

    Hi again, thanks for the clue. I was using jQuery 1.4.1 due to some other circumstances in my project. Now I'm using 1.4.2 and it works like a charm. I'll get back to you about the IE8 problem. I'll see if I can reproduce it at my Windows computer here at home. The problem occured at your demo page.

  • rick

    I think the question is how do you get an array of ids of the checked elements?
    Keep up the great work!

  • Dieter

    Hi, thanks for your fine plugin.
    I want (or should;-) change the style of the UI-Element to another color – IF there are options selected. Background: it should be used in a big search-form with 8 or more Multi-Selects.
    I explored the “close”-event – but how can I access the Multi-Select-Widget from within that callbackfunction? Is there a generic way? Or should I reference it with another

    jQuery('#id_of_element')

    call? Once I have the a reference, I want to call its getChecked-Method and add/remove a specific class for highlighting.

  • ehynds

    this will give you an array of checked values. customize to return whatever value you want:

    var array_of_checked_values = $(“select”).multiselect(“getChecked”).map(function(){
    return this.value;
    });

  • ehynds

    “this” in the callback is a reference to the select box. so in your case, $(this).multiselect(“getChecked”)

  • Tillclaes

    The problem with IE8 and Single Select appears at my Windows box at home as well. If you have IE8 available, try it with your demo page and you'll probably see the same.

    I failed to inspect it any further with Firebug though. Had to use Firebug Lite in IE and there seems to be a bug in Firebug Lite when inspecting your demo page – it failed with something like Access Denied.

  • Dieter

    Thank you. I must confess, with al little guessing/thinking I should have found the solution by myself…
    But another challenge: any clue how it is possible to change the height of the “dropdown” dynamically, in dependence of the item count (like a “real” dropdown)

  • ehynds

    I see it. the problem was with the demo,l there wasn't a name set on the select box. all fixed now.

  • David

    While showing my site to a friend, he noted that it would be nice if the option exists to show the dropdown in multiple columns. I've got one with 150 entries in it, would be just plain awesome if I could say, “put those in 3 columns” so that a lot less scrolling would take place.

    But I know that's probably not an easy thing to do.

  • E.mor

    Great job. I'm a having a problem when I use both “optgroup” in the select and the filtering plugin.
    In this case, the filter is not working, do you have the same problem?

  • ehynds

    another good catch.. i just updated the plugin: http://github.com/ehynds/jquery-ui-multiselect-…

    you'll have to pull the latest version of the widget & the filtering plugin. there are still some styling issues to address, like hiding the optgroup label if none of it's children match, but the logic should be pretty solid.

  • http://twitter.com/JeromeMeyer62 Jerome Meyer

    Hey,

    Can i use image + text in the options ?
    I can't find a way to do ti …

    Thanks

  • David

    The selected text wraps now when it gets to the end, any way to get that to go back to the way it has worked before, scrolling out of view? Or just chop it off? I can't have my buttons growing on me, but I'd hate to not use selectedText just because a few very large options warp the button.

  • ehynds

    Add these CSS properties to .ui-multiselect:

    .ui-multiselect { height: 25px; overflow-x: scroll; }

    I don't want to set this by default because I don't want to impose a fixed height. Play around with these properties though to fit your needs.

  • ehynds

    Out of the box, no… but once the widget is initialized, you can certainly add whatever you'd like to each list item.

  • Dieter

    any clue how it is possible to change the height of the “dropdown” dynamically, in dependence of the item count (like a “real” dropdown)

  • ehynds

    Set the height option to “auto”

  • Stefan

    Really great stuff!. Tried some others too, but luckily found this one.
    But one question: I need to update the option list after updating the underlying options. How can i do that?

    Tried destroy and reinitialize as a workaround, but it does not work either.
    It will simply append the new options without releasing the old ones.

  • http://twitter.com/deus_pater Mayank Thanawala

    Great plugin. I found it useful to add a method as follows:

    getAll: function(){
    return this.menu.find(“input”);
    },

    to get an array of all the checkboxes in the list (in my case, I wanted to automatically check/uncheck other boxes with identical text within other optgroups).

  • Roger Gales

    Eric, how close the menu with the options in Single Select after choosing the option I chose?

    It would be very interesting to put an option to choose whether we wish to close the menu by choosing the option.

    My code is as follows:

    $(“#cursos”).multiSelect({
    minWidth: 400,
    multiple: false,
    showHeader: false,
    selectedText: function(numChecked, numTotal, checkedItem) {
    vCodCurso = $(checkedItem).val();
    alert('closing…');
    $(“#cursos”).multiselect(“close”);
    alert('closed?');
    return $(checkedItem).attr(“title”);
    }
    });

  • David

    uncheckAll (not sure about checkAll) doesn't seem to work when the filter is present. Pre-widget my jQuery was finding the “none” link and clicking it. Any multiselect with a filter wasn't “none”-ing. Switched to using the uncheckAll method. Same problem.

    The only way either method (finding the link and clicking or using the method) works is if the multiselect “dropdown” is visible. When it isn't, no worky.

  • ehynds
  • ehynds

    I'll figure out a solution for you… the problem is that I have to detach the option tags from the DOM when the widget is initialized, otherwise the original select and the new multiselect would be sent during form submission. The other option I have is to keep the select in tact and just disable it, but then I run into problems with destroy() and trying to figure out which options should be re-enabled and which ones were originally set to disabled.

    Destroy/reinitialize definitely shouldn't be appending new options, so I'll check into that first.

  • rick

    Just wanted to say that I'me seeing the same behavior regarding new options being appended to the old options doing a destroy/initialize.

  • TomW

    Awesome awesome plugin! Any chance of having a “template” for the selected options so we could feed things like images and other styles into the items?

  • Martin Bergner

    How can I dynamically add <options> to the widget?
    (nice work btw ^^)

  • http://wildan.openthinklabs.com Wildan Maulana

    Thanks for the great plugin, i have little problem.

    how can set the default checked value on when using multiselect:false.

    I used this, but didn't work :

    $(“[name=driver_code]“).each(function(){
    if($(this).val() == data.driver_code) {
    $(this).attr('checked', true).trigger('change');
    }
    }) ;

    Yes, the radio get checked, but the header is not.

  • http://wildan.openthinklabs.com Wildan Maulana

    I have try the filter with single select (multiple:false), and the result is not accurate sometimes right sometimes wrong, but there is no problem on multiple:true.

    how stable is this filter ?

    Thanks!

  • http://twitter.com/taciomedeiros Tacio Medeiros

    Just a little concern related to widths. My multiselect is inside a dialog that is initially closed. So, when I call the plugin on my select element it is by that time hidden and thus has 0 width. I obersved that you set the width of the menu based on the width of the button which will also have no dimensions. As a consequence, the menu is rendered without a width css property and that caused me some layout problems on my form.

    I solved it for my particular case but don't know what would be the generic solution. Just mentioning it so that in future releases you'll have that issue in mind.

  • LiG

    Hi, great widget!

    I found an issue though:
    if I load jquery.validate.js in the same file as the multiselect, the selection of options doesn't update the text in the control. (as '1 item selected', 'x items selected', etc).

  • http://wildan.openthinklabs.com Wildan Maulana

    I thinks found the problem,

    i'm not using multiple=multiple attribute, and i'm add the extra <option> with 0 value …

    After using multiple attribute and remove the exprta <option> the filter works great ….

  • http://wildan.openthinklabs.com Wildan Maulana

    Found the solution ..

    The solution is, using .trigger('click'), but there is one more problem ..

    How can i pass extra data to this trigger and capture it on multiselectclick event ?

    .trigger('click',['edit'])

    ….

    .bind('multiselectclick', function(event, ui) …

    .., on ordinary click event we can get the data via second argument of click call back..

    .bind('click', function(event, extra_param))…

    What about multiselectclick event ?

    I hope the question is clear anough …

    Thanks!

  • Lrossy

    How can i limit the number of items being check to a certain number, lets say 5, i know it can be done with the $(“#multiselect”).bind(“multiselectclick”, function(event, ui){
    }
    method, but is there an easy way to do it?

  • Phil

    I have had this problem with a similar version of this. What do you mean by add brackets? I am using ColdFusion for server-side.

  • http://www.cregox.info caue

    This is amazing job Eric! I've being looking for auto suggest / complete scripts, and while there is all kinds of options out there and this is not in the same field at all, it is an alternative way of doing it, actually better for this specific need, and I can't believe this is open source, so easy to use, and works so good!

    Anyway, since you encourage feedback in here, I think I got a bug on the filtering. Try using more than 1 word per <option>. This is what triggered me (sorry for the portuguese):

    <select multiple=”multiple” name=”usuarios” id=”usuarios” style=”width:400px;”>
    <option value=”0″>teste</option>
    <optgroup label=”teste estatico”>
    <option>fulano da silva</option>
    <option>beltrano da silva</option>
    <option>ciclano oliveira</option>
    </optgroup>
    </select>

    if you search for “s” or almost any letter, it won't show the last 2 options. I will look in the code later on, since it's so small, and try to figure it out myself… But I just wanted to say it in here, in case you find this easy to fix. :)

    Thanks again for such a fantastic piece of work!

  • http://www.cregox.info caue

    Just an update, I'm positive the problem is actually with OPTGROUPS, but can't pinpoint where in the code – a lot to learn on jquery before I can easily handle this.

  • http://www.cregox.info caue

    Here is a “little” feature request list, in order of complexity (I suppose):
    - option to set the layout as a regular select multiple rather than combo dropbox (just like the <select multiple> would behave not for this widget)
    - auto complete / suggest search style, besides the filter
    - keyboard support

  • Games

    There is a problem with other submit buttons e.g. into cart. They won`t function with loading multiselect.js

  • Eddie Ridwan

    Eric, excellent widget.

    Is there any way to customise the options to be wider than the widget width itself? I am trying to avoid the option text wrapping, but need to keep the widget itself narrower. In the Safari web inspector I can simulate the required effect by explicitly changing the width of the ui-multiselect-menu element (which has an inline width). But I can't see where I can set this in css or in the javascript.

    Appreciate any suggestions.

    Thanks.

  • Khaled

    How could I change the state of one of the checkboxes to checked/unchecked?

  • Ilya Tretyakov

    Error on page in the example:
    // bind to event
    $(“#multiselect”).bind(“multiselectopen”, function(event, ui){
    // event handler here
    });
    It should be:
    // bind to event
    $(“#multiselect”).multiselect('widget').bind(“multiselectopen”, function(event, ui){
    // event handler here
    });
    I believe that $(“#multiselect”)[0] is the plain <select> in a HTML, right? No option, right! ;)

  • Ilya Tretyakov

    How about 'textChanged' event?
    It's so lazy to write this:
    $('#MySelect').multiselect('widget').bind('click checkAll uncheckAll',function(event, ui){ …
    Regards.

  • Ilya Tretyakov

    Bug!
    The “close” event may be attached only in the initialization.
    No one “someTing.bind('close',function(ev,ui){…” do not work.

  • Ericmbrancaccio

    Hello,
    I am trying to do a form POST but the values from the selects are not passed?

  • Rey

    Good job. I obviously have many of the feature requests that others have, but what about classes? It seems like any hope of doing different styles for different opt groups is out of the question. I understand that you're using themeroller, but why not put the option there for multiselect to optionally get the classes from the original elements? It severely limits what I can do.

  • jayway

    I keep getting:
    'this.button.contents().1' is null or not an object

    on this line in the jquery.multiselect.min.js (v1.3):
    return this.button.contents()[1].nodeValue=c

    Any ideas?

  • jayway

    It's a bug…specifying
    noneSelectedText: “”

    causes an error

  • ehynds

    The demo syntax is correct – you interact with the widget by referencing the original select box.

  • ehynds

    something like: $(“select”).multiselect(“widget”).find(“input:checkbox”).trigger(“click”);

    you would of course have to add some kind of filter to grab the checkbox you want.

  • ehynds

    See this demo: http://www.erichynds.com/examples/jquery-ui-mul…

    I'm trying to keep the API and code base to a minimum, but allow hooks to cover all these special cases.

  • ehynds

    set the selected=”selected” attribute on the option tag you want checked by default. when you transform the select into a multiselect, it will be checked automatically.

  • ehynds

    You need to bind multiselectclose – not close – and make sure you're selecting the original select element you initialized the plugin on.

  • ehynds

    What server side language? You may need to name your select box with brackets at the end – like “countries[]” – in order for your backend to pick it up.

  • Paul

    Is there already a solution for this issue? Adding the validate.js also stops most of the other functions of the multiselect.

  • retrocoder

    I to need to do this but am new to javascript and your control. Could you expand your answer as it's not too clear what you mean by filter.

  • Jharbour

    When I try the above code, the script fails. I've uploaded 1.3. Any ideas?

  • Jharbour

    To clarify, when I use the example “var array_of_checked_values = $(“select”).multiselect(“getChecked”).map(function(){
    return this.value;
    });”
    and output to an alert box to see the values I get [object object].

  • Anonymous

    this is normal behavior; you cannot alert a complex data type. use firebug and console.log() the variable.

  • Redbird

    Hi,
    I will put your control in a bottom bar, but, I don’t find how to open it up
    Any idea on it ?

  • prip

    Great job!

    How do I add and remove options?

  • Jharbour

    I realized my mistake yesterday and was able to get everything working. The only issue I have now is with the previous version when open the menu did not affect the other elements in the form. It overlaid them. This version pushes all other items down the page. Is there a setting to overlay?

    Great plug in by the way.

  • Philip Smith

    Very nice widget :) does almost everything I need for what I’m working on.
    I do have a question though and that is how (if possible) can I extract the index of a selected value, especially for lists where multiple: false.

    Thanks

  • Philip Smith

    In response to my own question, I’m doing something like.

    var options = $(“#DDL_AcademicYears”).multiselect(“widget”).find(“input:radio”);
    for (var i = 0; i < options.length; i++) {
    if (options[i].checked) { // do something with i }
    }

    Not sure if its the best way but it works.

  • Anonymous

    Fixed in the latest build…

  • Anonymous

    the code I posted will check or uncheck all the checkboxes. you’d probably want to target a specific one though:

    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(2)”).trigger(“click”);

    that’ll find the 3rd checkbox (0-based index) and check or uncheck it.

  • http://pulse.yahoo.com/_BTQTZ67JGJDW5PP4MPDDVSNSYM Ian

    Using the following code works fine to check the correct boxes but I seem to have found a bug. Even though 4 boxes will be ticked, the list header says “3 items selected”. If I un-tick one manually and then re-tick it, the heading correctly says 4 boxes ticked.

    months = ’1:3:4:11:’; //test data
    var args = months.split(‘:’);

    for (var i = 0; i < args.length; i++) {
    var id = args[i];
    if (id != ”) {
    index = id – 1;
    var s = $(“#ifmgr_sch_Months”).multiselect(“widget”).find(“input:checkbox:eq(” + index + “)”).trigger(“click”);
    s.checked = true;
    }
    }

  • Anonymous

    I fixed this a few days ago and will be included in the next release (coming shortly)

  • Chmalon

    Is there a way to make the option groups expand/collapsible? I would be working with large lists and it would be very convinient for this functionality, any suggestions?

  • Anonymous

    Why do you remove the OPTION elements from the original SELECT element during the formation of “this.button”? This causes selected values to be lost if a user navigates to another page and then tries to return to the page containing your multiselect by using the back button. When I remove the call to .detach() from the method chain that builds up “this.button” the multiselect appears to still function correctly. So for now I’ve removed the call to .detach().

  • http://pulse.yahoo.com/_BTQTZ67JGJDW5PP4MPDDVSNSYM Ian

    When I click on the list so that it drops down, the dropdown list is narrower than the list header (the bit that says select option). There is a gap on the left of about 1cm (the menu appear to be right justified but not 100% width). It appears to be part of the dropdown menu but is transparent. if I click in this space the menu doesn’t roll its self back up. Could this be a styling issue? I’m new to javascript and css so am not sure what areas to play about with.

  • Anonymous

    I changed this up in version 1.4, but the reason is so the original option tags aren’t posted in the form submission. It’s a very dicey thing trying to ensure:

    1. original option tags aren’t posted
    2. original option tags values are updated when a checkbox is checked (for destroy + progressive enhancement)
    3. widget retains the correct checked checkboxes when the page is refreshed

    there are three variations to make some of these work, but none will solve all 3 issues in one go:

    1. disabling the original select
    2. keeping it enabled but removing the option tags
    3. keeping it enabled but removing the selected value from each option tags

    Right now I’m on #3, but of course when you refresh the page the widget won’t retain the selected elements, because the selected attribute no longer exists on the original options. so, the fix here is to destroy the widget onunload, which restores the original element and the selected option tags, so when the page is reloaded it can re-init from the start.

    … which introduces another problem: it’s visually ugly to see multiselect turn into a regular select right before you leave the page.

    any ideas? :)

  • Anonymous

    there must be some css or js conflicting with multiselect. try reducing it down to the simplest thing that still breaks- you’ll probably discover what the problem is in the process.

  • Anonymous

    Would it be so difficult to simply keep the option tags in sync with the selected multiselect values?

  • Anonymous

    Yes – otherwise they’ll be submitted with the form as well and you’ll get duplicate values.

    Also note that if you simply disable the original element, when you refresh the page the multiselect will then be disabled, as it picks up on the newly added disabled attribute.

    I think i’m going to stick with how I have it, because at least this way I can give users the option of performing an onunload event to destroy the widget. I really can’t think of any other way.

  • Anonymous

    I’ll toy with this a bit and send you whatever I come up with.

  • Anonymous

    now that I think about it, if I remove the name attribute from the checkboxes then those won’t be posted to the server. therefore, I can make sure the underlying option tags inherit the selected attribute and only those will post. should solve all 3.

  • Anonymous
  • Anonymous

    Just finished reviewing the code and testing 1.4.1. Looks and operates great! Glad I could contribute to your latest enhancement. I have a few other ideas but I’ll share those when I get to that part of my project.

  • http://twitter.com/sedatkumcu Sedat Kumcu

    Thanks, thanks thanks for this plugin. Best regards.

  • http://twitter.com/sedatkumcu Sedat Kumcu

    hello again. i am use this plugin. But my first(!) list item selected by default. http://i56.tinypic.com/10qc5e0.png

    I solved this problem follows,
    add .multiselect(“uncheckAll”) to after initialize. http://i53.tinypic.com/2rf55l1.png

  • http://twitter.com/sedatkumcu Sedat Kumcu

    Hi again :) i forgot to add multiple=”multiple” to tag. my problem solved.

  • Anonymous

    Yep- most browsers will automatically select the first option tag by default without the multiple attribute.

  • http://twitter.com/mezzin mezzin

    Hi found a little bug in the filter code when an option has no value the cached array is not build right (with the empty value while the multiselect doens’t have the element)

    updateCache: function(){
    var isOptgroup = this.instance.optiontags[0].tagName === “OPTGROUP” || false;

    this.cache = this.instance.optiontags.map(function(){
    var self = $(this), nodes = self;
    if($(self).val().length>0){
    // account for optgroups
    if( isOptgroup ){
    nodes = self.children();
    }

    return nodes.map(function(){
    return this.innerHTML.toLowerCase();
    }).get();
    }
    }).get();
    },

    This code will fix it (it is a quick hack but it works)

  • Marcus Leon

    Great plugin! A couple bugs (I think):

    In Chrome, if you click the “Select Options” text, the option list does not appear. Works if you click the select box area to the right of the text – but doesn’t work if you click the text. This is confusing..

    In IE6, the first option in the select options list does not appear. It’s there but the text is the same color as the background so you can’t see the text.

  • Anonymous

    thanks Marcus. I fixed that chrome bug last week (http://github.com/ehynds/jquery-ui-multiselect-widget/commit/367300f7b11507e897f658dc0377cfcabbc119a2), but will look into the IE6 bug. Do you have the multiple=”multiple” attribute set on the select box?

  • Marcus Leon

    Cool, thx. Realized that the IE6 bug seems to be dependent on the theme. Bug occurs with the Flick theme but does not occur with the Redmond theme.

  • Marcus Leon

    We have a left nav with two MultiSelect boxes and then a submit button all in a single “column”.

    We’d like to be able to have the two MultiSelect boxes always open. Currently it appears only one can be open at a time. And if you open the second box this covers the submit button. We’d like to display two open boxes and a submit button at the same time so users don’t have to open/close the boxes when they select items.

  • dolly

    Liked your Plugin – But, have some issues to discuss.(Please help)

    In my application we have portlets.In one portlet i have a scrollable table and in that table i have select boxes to which i am going to apply your MultiSelect plugin.

    This is my first issue:
    In IE7 or IE8, i have two select boxes in a scrollable tabe within portlet lets say above and below(close together).If i click “Select Options” in first select box, i can see “Select Options”text in second select box as well.The control that is closer to the bottom of the screen is not being overlaid by the drop down menu of the above control.But, this works fine in FireFox.Not able to figure out the problem tried all…(Hope you understand).

    Thank You!!

  • Chris

    I just found a small bug :) In 1.4.1 version when the options is set to multiple: false the radio buttons do not have a name attribute thus multiple options may be selected (and there is no way to uncheck). A name attribute should be added to the input tag created at line 102 :)

  • Anonymous

    I fixed this last week: http://github.com/ehynds/jquery-ui-multiselect-widget/commit/4edd7e0bc87769aac69d61c4d81219a4fee81194

    The inputs can’t have a name attribute or the values will be submitted with the form twice. When a box is checked/unchecked, the original select element is modified and that is what actually posts to the server.

  • dolly

    Hello again,

    I have an issue with multiSelect plugin.In my application, I have couple select boxes which will be converted to multiselect control. As soon as i reach that page i should have one select box to be open.I tried using state:open.But, didn’t work its effecting all the select boxes in the page.I am using same style class for all the select boxes.I could not figure it out.

    Any help would be greatly Appreciated
    Thanks
    dolly.

  • dohomi

    Hey there, this plugin looks really fine! But I have trouble with a dependency between 2 dropdown fields? The method ‘update’ didnt work for me…Is there some workarround forf it?

    Greetings domi

  • Shani

    Hello,
    This is a great tool.
    I use the jQuery MultiSelect and it works great but I have a problem with the filter -

    1)When I click on the filter box (to start typing), the click event of the MultiSelect widget is being trigger.

    2) when I try to write something in the filter I get a warning : “The ‘charCode’ property of a keydown event should not be used. The value is meaningless.”

    Any ideas what can I do to stop it?

    Thanks,
    Shani

  • Anonymous

    thanks for reporting these. keep on eye on github for the fixes.

  • dolly

    Is there any work around for my problem.

  • dolly

    I think this is a bug in multiSelect plugin.I found this as an open issue.Waiting for this to be fixed soon…I welcome any ideas on this.

  • Anonymous

    works for me? http://jsfiddle.net/ehynds/9XrUb/

    Make sure you’re using the UI widget version. the param is “autoOpen”

  • pdecaux

    When you click on the OptGroup heading, all options in the group are selected, which is a nice touch. However, selecting options in this way is not caught by the “max checked” function. Any ideas?

  • http://pulse.yahoo.com/_LWDBWYN3K2UIP27SAY3OTXHPHM Kevin

    Eric, great job on the multiselect widget! I have a technical question I was hoping you could answer. How can I show the values which are checked on another part of the page?

    I have been trying with jquery but to no avail:

    $(“select[name=myMultiselect]“).click(function(){
    $(“#multiselect-preview”).html($(this).val());
    });

    It seems like there must be a better way. Any suggestions?
    Thanks,
    Nolan

  • Anonymous

    You almost got it- bind to the “multiselectclick” event instead of just “click”. It passes two params: event object, and a “ui” object with three keys: value (value of input clicked on), text (text of input), and “checked” (boolean denoting whether it was checked or unchecked).

    You could also call the getChecked() function instead multiselectclick to find all currently checked options.

  • Cris

    Hello

    I try to use it in a form with a reset button.
    here is my code:
    var multi = $(“#groups”).multiselect({
    selectedList: 4 // 0-based index
    });

    $(“:reset”).button();

    $(“:reset”).click(function() {
    alert(“reset”);
    multi.multiselect(“update”);
    })

    but the multiselect widget is only sync on the second click on the reset button.

    How i can reset the multiselect in the form?

    cris

  • dolly

    Daniel,

    I have the same issue going on in my app.Did you find any work around?

    -Thanks
    Dolly

  • dolly

    Thank you for the reply.

    I am using jquery UI 1.8.4 and jquery JS 1.4.2 versions.My application is in IE8.But, i am not able to work with autoOpen.Some how, its not working in my environment.I found out some difference between my multiselect.js file and your multiselect.js file which you provided in the above url.I copied your multiselect.js file and placed in my application but still not able to recognize autoOpen. Am i missing something??

    Thanks
    dolly.

  • Sumit

    Great functionality very similar to what I am looking for, but as Caue requsted, would it be possible to use an Autosuggest like feature instead of the Filter. The match should be open to match parts of each list item. I dont know / have not seen enough on the Filter document to be able to configure /customize this.

  • http://pulse.yahoo.com/_LWDBWYN3K2UIP27SAY3OTXHPHM Kevin

    Banging my head on desk. Still trying to use multiselectclick to show the checked values elsewhere on the page… Could you PLEASE demonstrate this on JSfiddle? Thanks for taking the time, I am still learning. Again, great job on this one. -Nolan

  • Anonymous

    hey, how does this look? http://jsfiddle.net/ehynds/rTjkr/

  • Anonymous

    you might be using the plugin version which is still on github, but no longer on this website. I’m not really supporting it anymore. try upgrading your code to this new UI widget version. See the first part of this post for what you’ll need.

  • gillbates

    love the widget. for some reason i am not able to bind new values in the dropdownlist. if i dont use this widget, i am able to bind the values via a JSON call. however, once i initialize the dropdown
    with $(“#myddl”).multiselect();….it doesnt pick up the new values. anyone else encountered this? anyone know how to fix this issue? thanks.

  • codeFoo

    I had this same issue. I upgraded to the 1.7 version of the validate plugin and the multiselect started functioning correctly again.

  • http://pulse.yahoo.com/_5BXAKHMYBJFILBZNQAZOSXJ6WM Alexei Ch

    Hello,
    could you please give an axample of how to use ‘setOption’ method. Thanks.
    I try to call it with arguments as a map or as function arguments, but this doesn’t work in my code.

  • http://pulse.yahoo.com/_5BXAKHMYBJFILBZNQAZOSXJ6WM Alexei Ch

    when I need to update multiselect widget after call to new JSON data, I just kill it, append new “option” field and initialize new widget:
    $(“#countries”).multiselect(“destroy”).empty().append(toOpts(val)).multiselect({…});
    toOpts is my function for building new option form field.
    It works smoothly even in IE6.

  • Anonymous

    setOption is used to change one option at a time after initialization. So like $(“select”).multiselect(“setOption”, “noneSelectedText”, “Please check something”);

  • https://me.yahoo.com/ruveloper#968d2 Your Name

    Many thanks! It works :)

  • Mircea

    I used the jquery plugin clearonfocus, so after filtering, checking an option, the input is emptied on focus and you can type a new search.

    I added a button to the filter plugin, near the input box, “clear filter”. I want it to reset the filter (empty the input box and show all options). Nothing I tried worked, I could only empty the input.
    How can I show all options again without keyboard input?

  • dolly

    Did you find any work around for this issue??

  • dolly

    Yes..your right.Thank you for the reply.It works:)

  • domi

    Great tool! Is it also possible to get the checkbox values from the server via ajax? Can I use the ‘before open’ for it? Thanks domi

  • Chris Maddock

    I have something similar in the same function ‘this.instance.optiontags.0.tagName’ is null or not an object, but the above code doesn’t fix this, presumably because it is outside the if statement that you added, any ideas?

  • domi

    Hello,

    very nice widgtet, but for the handling with multiple=’false’ there is no way for unselect the field again. Would be nice if this would be possible
    domi

  • Kevin

    I wanted to say that this is an incredibly useful piece of code. I wanted to see if a solution to this particular feature had been found?

  • http://www.paul-apostol.ro Paul Apostol

    Hello,
    @dohomi:
    1) I got the values with ajax and I rebuilt the original select. After that $(select).multiselect(“destroy”).multiselect({…});
    2) You have to add an option to the original select that represents that is not selected. Maybe Nothing
    @ehynds: the widget is great.
    two things to say:
    a) the widget doesn’t fire the change event, I’ve made some test and adding at the end of line 280 .change() did the trick
    b) I can’t change from outside the RexExp for the filter. I need it jus a little bit different. Do you think is feasible to expose it and to allow to be changed?
    Regards,
    Paul

  • http://www.paul-apostol.ro Paul Apostol

    Oops,
    There is a chance to invert the comments order of your blog?
    Regards,
    Paul

  • Anonymous

    Good point. I should probably change the checkbox click events to change. Exposing that logic sounds good, I’ll see what I can come up with.

  • http://pulse.yahoo.com/_5BXAKHMYBJFILBZNQAZOSXJ6WM Alexei Ch

    But, at least, changing “noneSelectedText” seems does not work – I forked your example http://jsfiddle.net/95qVr/2/

  • Anonymous

    where are you changing the option in that fork?See this: http://jsfiddle.net/ehynds/95qVr/4/

  • http://pulse.yahoo.com/_5BXAKHMYBJFILBZNQAZOSXJ6WM Alexei Ch

    The right link of the version where it didn’t work was http://jsfiddle.net/95qVr/2/

    The issue was that the right method name is “option” (you used in your example), but not “setOption” as you wrote. Now it works too http://jsfiddle.net/95qVr/6/ :)

  • http://pulse.yahoo.com/_5BXAKHMYBJFILBZNQAZOSXJ6WM Alexei Ch

    When I upgraded widget from 1.3 to 1.5 I’ve found the next issue with radio type: when I get field value on “click” event, it returns both previous and current values (what is impossible for true radio)! See http://i.imgur.com/i9x3h.png
    Because the old value isn’t unchecked before the new value gets checked.
    Added an example http://jsfiddle.net/95qVr/7/

  • http://www.paul-apostol.ro Paul Apostol

    Maybe it’s not the best solution, but for the moment will do. I added the next options:
    instName: ‘multiselect’, expression: “‘\\b’ + term”. First is because I massacred your extension to produce listbox and I named ‘listselect’ ;) . The second is the string expression for the search, where term is the searched text. (I know you know, it’s for consistency)
    instead of line 82 I’ve put:
    var str = ”;eval(“str=”+this.options.expression+”;”);var regex = new RegExp(str, ‘i’);

  • http://pulse.yahoo.com/_LWDBWYN3K2UIP27SAY3OTXHPHM Kevin

    Brilliant. Thanks Eric. Again, great job on this one.

  • Mike

    Hi Eric. Great plugin.

    Your single select demo doesn’t seem to work in IE7 though. I’m using IE8, but setting Browser and Document mode to IE7 in the Developer Tools. Not sure if that makes a difference, I don’t have access to a native IE7 browser at the moment.

  • Mike

    I changed a line of your code to add a name attribute when drawing the radios and it seemed to fix the issue. I opened an issue and posted my change on github.

  • https://me.yahoo.com/ruveloper#968d2 Your Name

    yep, this bug broke everything :)

  • Anonymous

    Fix has been committed… stand by for a release this week.

  • Anonymous

    To all those having issues with single selects and/or IE7, please read the comments thread on this bug: http://github.com/ehynds/jquery-ui-multiselect-widget/issues/closed#issue/31

    In short, it’s been fixed, just be prepared to see some extra data being passed down the pipe during form submission. Shouldn’t affect anyone, and there’s nothing you’ll need to do. I hope to push a new release this week I just need more time to test. All associated unit tests are passing in IE7, 8, FF, Chrome, etc.

    Two form reset tests are failing in IE but it has to do with how I’m attempting to test it, not with the functionality itself.

  • Paul

    thanks very much. Good jobs !

  • Anonymous

    Can you setup a demo on jsfiddle.net? I’m unable to reproduce.

  • Anonymous

    fixed in version 1.6.

  • Anonymous

    1.6 is out – all set!

  • Paul

    Thanks it works !

  • Paul

    oops ! I’m sorry but the bug wasn’t fixed. I think it works but only work one. In second It failes…. :(

  • Anonymous

    I updated your demo on jsfiddle and both are working: http://jsfiddle.net/95qVr/8/

  • Paul

    Hello,

    Here’s an example that not work with version 1.6. I prefer to give you all

    Here : http://paul.borel.free.fr/erreurMultiselect.zip

    Thanks

  • Bas

    Is your select box inside a table? I had the same problem and it only seems to occur when the select is inside a table. As a workaround you can hard code the width in the jquery.multiselect.css file. Just add width: [num pixels]px; to the .ui-multiselect-menu entry.

  • domi

    Hello Paul,

    I got it work with a quite rough part of coding. I have a related/depended multiselect on which I make a click event, and there I print the subcat new with
    j(‘#subDiv’).html(data);
    j(‘#subcategory’).multiselect();
    But Its not the best solution…

  • domi

    Hello Eric,

    I found a little bug or browser-dependend issue: If you want to use the multiselect for a searchform more than one time on a page and you change some values and click on a link, Firefox 3.6 keeps only the first multiselect values, all other multiselects loose their selection. In IE8 and chrome everything works as expected. Any idea? –> The first time, that IE beats Firefox :)

    Have a good day! Cheers domi

  • Wade

    Hi Eric,

    I’m a bit confused as to what happens upon browser refresh (F5 key).

    I built a basic HTML page (no server attached) with 3 multiselects (of 3 entries each). I also made sure selected=selected was on for all values. When I hit the page for the first time, I have 3 lists w/ 3 selected in each, as expected.

    In Firefox, if I uncheck any of the entries in the first list and then refresh the browser, it saves the result. If I uncheck anything in the 2nd or 3rd list, it will not save my result when I refresh the browser.

    In IE8, it’s a bit different. It will actually save any changes I make in all 3 lists after a browser refresh.

    Both of these behaviors surprised me. I figured that a browser refresh would always reload the original values from the HTML file and never save any changes I made. As well, I added the META tag to disable caching, but it had no effect on either browser.

    So what exactly is going on here ? I can send you the zipped example if you wish…..

    Thx,
    Wade.

  • Netanel

    Has any one found why this happens? It happens to me only only when using the widget with the multiple version.
    Can it be related to the jquery-ui custom css? The datepicker I’m using is to large too.

  • Anonymous

    It basically depends on what the browsers do with a vanilla multiple select input. MultiSelect just sets the selected attribute on the original option tags, so when you refresh, the options multiselect set should still be selected. I’ll put some tests together and see what’s going on.

    To my knowledge, a browser refresh will not reload original values, only a hard refresh will. So this is either an inconsistency between browsers or a bug in multiselect, but my first inclination is that the browsers are handling this differently.

  • Wade

    Thx for the insight. I didn’t know there a difference between a browser refresh vs. a hard refresh behavior. Now I do : )

    Regarding this issue, I’ve done a bit more testing. I compared the behavior with multiselect on vs. off in both browsers using the 3 list example.

    IE is good with no issues. With multiselect on or off, the selections are always retained from the pre “browser refresh” state.

    Firefox (3.6.12) has an issue when multiselect is used. With multiselect on all 3 lists, a “browser refresh” will only retain the values on the first list. Lists 2 and 3 always revert to the original selections from the HTML file.

    But with multiselect turned OFF (on the same example using Firefox), the behavior matches IE (or the expected behavior, as you described before).

    Hope this helps.

  • domi

    Hello Eric and Wade,

    the F5 refresh handling is the same behavior like the history back button on different browser. Its browser dependent, every multiselect after the first one loosing its selected content after refresh or coming back from a singleView in FF, but not with Chrome or IE. Greetings domi

  • Nils

    Hi Eric,

    What a very good widget … very nice!
    I’ve got a question: how to inline the created select box?
    Indeed, the multiselect seems to always be positionned as a float:left. But I’d like to make it inlined in the same line as other fields.
    I’ve looked in the help but nothing about positionning the full widget.

    Do you have an idea?

    Many thanks

  • domi

    Hi Eric,

    I just tried out your plugin with the filter plugin and . There is an javascript error, if you start filtering and then click on an optgroup element, where is no checkbox available. You also can see the error on your demo page.

    I also think it might be a perfect option, when the labels will hide, coz in some cases there are many labels and no checkboxes to coose if you start to filter. Or maybe that you trigger the labels of to hide / show each checkbox-elements.

    THX for this great work, domi

  • -=JFK=-

    AMAZING JOB!!! Truly outstanding coding done on this widget. Would it be possible for you to put a jquery.multiselect.filter.min.js file in github? and e-mail me if you do this?

  • dolly

    Hey Eric,
    I used Multiselect plugin in my application.I thought by default i will get vertical scrollbar.But, i don’t. Any ideas regarding this?

  • Tiago

    Hi friend, nice job. When you say “there are still some styling issues to address, like hiding the optgroup label if none of it’s children match, but the logic should be pretty solid”, I’m with this same issue. I want to hide optgroups with no filtered match. Could you give me some idea? thanks a lot.

  • Brams_3

    Hello,

    Im trying to retrieve the values of the multiselect on the server. It is working great. However there’s a problem when dealing with optgroups.

    If the entire list of 20 items is not checked, and i clicked on an optgroup that contains for example 3 items, on the server side all 20 items are submitted and not the the selected 3. However if you manually click on the 3 items one by one without using the optgroup, on the server side only 3 are received.

    Is this a bug or am i missing something? Appereciate your help

  • Anonymous

    That’s definitely a bug. I’ll check it out asap.

  • Anonymous

    do you have enough items to cause a scrollbar? I think the min height is 175px, or something similar, so you can either adjust this value or push enough items into the list to cause a scrollbar.

  • Anonymous

    The multiselect isn’t floated left; only the icons within the menu and inside the button are floated. It should inline naturally as the button is an inline element by nature.

  • Martin Makundi

    Hi

    This is a very nice component, but I would need to integrate it with jquery.change in order to notify server side when user closes the select and selection has changed. This jquery.change is nice because it does not fire fantom events when user happens to counter toggle (set-and-unset) a selection.

    **
    Martin

  • Martin Makundi

    I tried attaching jquery.change to multiselect but could not, any idea how it could be done?

  • http://twitter.com/yogee88 yogeswaran

    The check box selection at the drop down list is NOT retained after the result is being populated.
    i want those checked options checked once again after search option listed

  • Anonymous

    Are you setting the selected=”selected” attribute for the options that should be automatically checked?

  • http://twitter.com/yogee88 yogeswaran

    no…

  • http://twitter.com/yogee88 yogeswaran

    no…

  • http://twitter.com/yogee88 yogeswaran

    i got the solution…here is my code…

    if (_all != null && _all != “” && _all != undefined && _all == “ALL”) {
    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(0)”).trigger(“click”);
    }
    if (_licensed != null && _licensed != “” && _licensed != undefined && _licensed == “LICENSED”) {
    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(1)”).trigger(“click”);
    }
    if (_custom != null && _custom != “” && _custom != undefined && _custom == “CUSTOM_PRINTED”) {
    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(2)”).trigger(“click”);
    }

    if (_promotional != null && _promotional != “” && _promotional != undefined && _promotional == “PROMOTIONAL”) {
    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(3)”).trigger(“click”);
    }
    if (_clearance != null && _clearance != “” && _clearance != undefined && _clearance == “CLEARANCE”) {
    $(“select”).multiselect(“widget”).find(“input:checkbox:eq(4)”).trigger(“click”);
    }

  • Thom

    LOVE the control. It might be worth putting a note on the requirements page saying it’s incompatible with versions of the jquery validation plugin earlier than 1.7. I had to some searching to figure out why it wasn’t working properly at first.

  • Shuba

    hi this widget works perfectly for me! thanks a lot.But I do encounter a problem.All of my select boxes in the form changes into multiselect dropdown with checkboxes which i dont want for all but for one only.So how could i make this widget work for only one of my select box specifically.

    Thanks in advance.

  • Shuba

    hi sir, can this be accompanied with ajax? i ask this because when tried doing this with ajax, i found the styles and checkboxes would appear no more even when the respective css,js files are included in php file called via ajax? So may i know if anything is wrong in my coding style?

  • Anonymous

    Select the element by ID, name, or some other unique value. e.g, instead of $(“select”), do like $(“#foo”) or $(“select[name=foo]“).

  • Anonymous

    You need to call multiselect() inside the success callback of the AJAX call.

  • Anonymous

    Why not just set the selected attribute?

  • Anonymous

    Good call. I updated the “how do i…?” section of the post.

  • http://twitter.com/fabien7474 fabien7474

    Hello,

    I would like to use the jQuery UI multiselect plugin for selecting multiple countries. Also, I would like to display country flags together with country names in each select items.

    Is it possible? If yes how can I do that?

  • Anonymous

    $$.multiselect(“option”, “selectedText”, “some new text”);

  • http://twitter.com/brianstarke Brian Starke

    I see it’s been asked before, but I didn’t see any answers : is there anyway to dynamically add options to a multiselect widget? Multiselect doesn’t even acknowledge the options I added before calling upon the widget. Sample code :

    $.get(‘/data/options/for/multiselect’, params, function(options) {
    for (var o in options) {
    $(‘#multiselect’).append($(“”).
    attr(“value”, options[o].value).text(options[o].text));
    }
    }, ‘json’);

    $(‘#multiselect’).multiselect();

    pretty version at https://gist.github.com/5f302539885af06aecec

    Not having the ability to interact with the content of the select box and have it reflected in the multiselect widget seems like something simple that I’m missing. Any answers to this one yet?

  • Anonymous

    That gist is fine, except you need to put the call to multiselect inside the $.get success callback. $(“#multiselect”).multiselect() doesn’t wait for your AJAX to come back.

  • http://www.hermanvdmeulen.nl Meulentje

    Amazing! Just what I needed! Thanks!

    Herman van der Meulen

  • Shannon

    Be sure to initialize buttons before multiselect.
    My experience was the multiselect button (I was calling it a header) was not being updated.
    In multiselect 1.6 (current at this post) the span than holds the text (# of # selected) is saved in the multiselect data.
    I was causing myself pain by initializing buttons after multiselect, e.g.:
    $(‘select’).multiselect();
    $(‘button’).button();
    Which causes the multiselect button to be redefined and the reference held by multiselect is then a non-displayed span. It thinks it is working fine but is updating an orphan DOM element.
    The value in the multiselect code at line 394:
    this.buttonlabel.html( value );
    is correct, but ‘buttonlabel’ is an element with no parent.
    Fix this by changing init to:
    $(‘select’).multiselect();
    $(‘button’).button();
    Or by talking Eric into a bit of extra defensive code :)

    P.S. thanks for the great widget, Eric. I’m using it in a new app I’m writing. Maybe you’d consider not to .delegate mouseovers at the document root? That’s a kinda heavy load, isn’t it?

  • Shannon

    another quick comment,
    I do:
    $(‘ul.ui-multiselect-checkboxes input:checkbox’).removeAttr(‘name’);
    After initializing multiselect to prevent jQuery.serialize() from serializing and posting the multiselect checkboxes with private names.
    I hope the names aren’t used for anything important :)

  • Mani

    Hi Eric,

    I am trying to print the MultiSelect boxes from ajax but some reason it did not work for me. Could you pleasae kindly help me on this

  • Anonymous

    That is fine. You might run into issues when setting the “multiple” option to false, but I assume you’re using the widget as a multiple select.

  • Anonymous

    Just curious, why transform the button into a UI button when multiselect applies themeroller to it anyway? Also, mouseenter/mouseleave are rooted from the multiselect menu, not the document root.

  • Shannon

    ah, great info. you are correct. thanks!

  • Shannon

    I’m transforming other buttons, the form submit button in particular. I did not know multiselect generated a button element until I started debugging this issue. I could have applied it to individual specific elements, but it seemed semantically correct to transform all button elements on the page to theme-rolled at once when I laid it out, assuming that if other forms or submit areas were added they should follow the same style.

  • Shannon

    oh, and thanks for the reply about delegate, awesome! I wasn’t paying close enough attention to the dot context.

  • http://twitter.com/fabien7474 fabien7474

    Nobody can help me here?

  • Bill Walz

    Hi Eric, I had an issue with email addresses in my option values. The “Joe Somewhere ” was not being displayed just the name. The “” were not being escaped. I changed this line in the update function:

    Was:
    this.buttonlabel.html(value);
    To:
    this.buttonlabel.text(value).html( );

    This solved my issue the email address now shows up in the label.

    Cheers, Bill

  • markB

    Hi, how can we add a submit/apply button inside the multiselect?

  • Anonymous

    what do you mean? it’s more appropriate for a submit button to go outside the control.

  • Jcoetzee

    Had issue with IE7 that the dropdown was overly wide, but on refreshing the page, fixed the issue.
    Changing the following code seems to have fixed the problem.
    // set menu width
    _setMenuWidth: function(){
    var m = this.menu,
    width = this.button.outerWidth()
    -parseInt(m.css(‘padding-left’),10)
    -parseInt(m.css(‘padding-right’),10)
    -parseInt(m.css(‘border-right-width’),10)
    -parseInt(m.css(‘border-left-width’),10);

    m.width( width || this.button.outerWidth() );
    },
    To this.
    // set menu width
    _setMenuWidth: function () {
    var m = this.menu,
    width = this.button.outerWidth()
    - parseInt(m.css(‘padding-left’), 10)
    - parseInt(m.css(‘padding-right’), 10)
    - parseInt(m.css(‘border-right-width’), 10)
    - parseInt(m.css(‘border-left-width’), 10);
    m.width((width || this.button.outerWidth()) <= 0 ? this.options.minWidth : (width || this.button.outerWidth()));
    },

  • Anonymous

    Not at the moment, but I like that idea a lot. Maybe soon :)

  • Anonymous

    Looks like you haven’t included the jQuery UI widget factory correctly.

  • Shannon

    Eric, more useless ideas for you. I find it necessary to do this:
    var button = $(‘#searchCriteria button.ui-multiselect’);
    button.attr(‘tabindex’, button.prev().attr(‘tabindex’));

    Thanks again for the great widget!

  • Shannon

    I was waffling on Eric’s multiselect vs. jQuery’s selectable for this reason. Of course, I chose multiselect, because it’s better :)

    Selectable has a lead developer with a very specific idea of what it should do (emulate desktop drag-select interactions), and despite numerous requests to enable a default left-click-single-select-mode won’t increase the scope of the widget. So, if that interaction fits your needs, you might consider it.

  • Michi

    I would like to style my select using optgoups with multiselect. I need to have my multiselect wide and optgroups floating next to each other in two columns. Is this possible?

  • John

    This widget is great, however, I’m getting an error when trying to use it with an ASP.NET ListBox. Has anyone used this with a ListBox successfully?

  • Anonymous

    What does the error say?

  • Bill Clintons

    How do I stop the menu items from bolding on hover? It looks terrible, like they are warping?

  • Hillary Clintons

    It really sucks that the only way to change this results in the selected text at the top also being unbolded. Such a great control. I hate to be a troll because the control is genius but I can’t believe no one notices how crappy bolding the menu items on mouseover is.

  • Anonymous

    I personally don’t mind the look. To remove the bold on hover. just override jQuery UI’s theme:

    .ui-multiselect-checkboxes label.ui-state-hover { font-weight:normal; }

  • Chris

    A small issue with the 1.7 version and filtering – now if we have multiple == false the header will never show up, so even if we use the filter addon it will never show up for a list of radio fields.
    Instead we should only hide check / uncheck all links if multiple == false not the header (line 157).

  • gdi

    Hello, i’m having a problem with the filtering plugin and i can’t make it work right. When you search something and insted of clicking to check the result you choose to click “check all” and then send the post to the server, when it comes back, all items (even the ones that were shown ‘cuz of the filter) returns checked.

  • Bill Clintons

    Right on! Thanks Man!!!

  • IE

    Is there a way to hide the optgroup labels if there are no items available in the filtered group?

  • Anonymous

    Can’t you just set the header to true if you plan on using the filter widget?

  • Anonymous

    Not at the moment, but it’s in my radar.

  • Iubianz

    how can we validate it? means at least an item is selected?

  • Anonymous

    validate it as you would a normal select. All multiselect does is interact with the underlying select control, so if an item is checked in multiselect, then the same option tag will be selected.

  • Anonymous
  • thomas

    Just incase anyone else had the issue of their label running out of the widget, here is a small hack I put in place:

    in the options: { .. }; add the option for “width: false,” and pass a specific width you want.

    update _setButtonWidth to be this:

    _setButtonWidth: function(){
    var width = this.element.outerWidth(),
    o = this.options;

    if( /d/.test(o.minWidth) && width maxLength){
    var x = 0;
    displayValue = ”;
    while(x < maxLength){
    displayValue = displayValue + value[x];
    x++;
    }
    displayValue = displayValue + "…";
    }
    }
    // End bleeding over

    this.buttonlabel.html( displayValue );

    There is also a minWidth that is defined and you can modify this to work witht hat instead. I just had a ton of code written from previous versions that did not support a minWidth or width at all.

  • IE

    Fantastic!

  • IE

    Is there a way to re-initialize a list faster than setOption? I’m looking to build dependency between a few lists that populate with options depending on what was selected in a previous list. I would be pulling data via ajax but would be nice to have a function to pass an array of name, value pairs.

  • Iubianz

    I am using this code…

    function Valdation()
    {
    if ( document.getElementById(‘categories’) == -1)
    {
    alert ( “Please select a Location.” );
    return false;
    }
    return true;

    }

  • Iubianz

    Thanks , i have done by this method:
    function Valdation()
    {
    if ( $(“#categories”).val() == null)
    {
    alert ( “Please select a Location.” );
    return false;
    }
    return true;
    }

  • Doug

    Hi

    I am using this control on an ASP.net 2.0 website. After the multiselect is closed (ie after a user has checked / unchecked options), I would like to do a postback and execute some server-side code in the codebehind. What do I have to do to achieve this? My JQuery knowledge is somewhat limited :)

  • Anonymous

    Hi Doug, take a look a this demo:

    http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#callbacks

    Basically define a “close” callback and do your XHR request in there.

  • thomas

    Hi,

    With the latest Multiselect and Filter plugin it seems that when we set ‘multiple: false’ it breaks the fliter plugin. Thoughts?

  • http://twitter.com/SteveWilhelm Steve Wilhelm

    I am trying to place two Multiselect lists on one row by setting the class “selection_row” and in my style.css setting “.selection_row { display: inline}”. It appears some code automatically adds style={display: none} to the select and overwriting the CSS style. Any thoughts?

  • Anonymous

    Must be some conflict in your own CSS. Multiselect doesn’t touch the display property. See this demo: http://jsfiddle.net/UMqcy/

  • Lee

    I’m having trouble with the noneSelectedText showing up on when using the multiple:false option. See http://jsfiddle.net/YtYYf/

  • Anonymous

    it’s “noneSelectedText”, not “noneSelectedTest”
    :)

  • Lee

    Oops! But it still doesn’t work.

    http://jsfiddle.net/owens2024/YtYYf/2/

  • Anonymous

    Thanks, i’ll look into it.

  • http://twitter.com/AugiCZ AugiCZ

    Hello,

    very nice widget – I have one suggestion and one bug report (probably).

    Suggestion: It would be nice if “multiple” option would be “undefined” by default which would mean that “multiple” value is automatically inherited from “multiple” value attribute of underlying “select” element.

    Bug report: I would like to use this widget as ComboBox, so I set “multiple” option to false. The problem is that the widget doesn’t load the selected option – so none options is selected (additionaly, if none of options is selected then the first option should be selected by default).

    Try to use the widget on following code:
    12345

    If I use this then none option is selected.

    Thank you!

  • http://twitter.com/AugiCZ AugiCZ

    Ah, the same problem (no option selected) as I reported – sorry for duplication…

  • Hrecho

    I used 2 combos dependant accordingly
    I know this definitelly is not a optimal solution but may be it can help to someone
    Eryc would you recomend to me some change?
    Thanks, great component.

    var destCountries = new Array(32);
    var destNames = new Array(32);
    destCountries[8]=10;destCountries[27]=12;destCountries[14]=9;destCountries[34]=9; destNames[8]=”Alanya”;destNames[27]=”Amalfi”;destNames[14]=”Antalya”;destNames[34]=”Ayia Napa”;
    function getValues(cid){
    var opt = ”;
    for (i in destCountries) {
    if (destCountries[i]==cid){
    opt += ”+destNames[i]+”;
    }
    };
    return opt;
    }
    $(function(){
    $(“#country”).multiselect({multiple:false});
    $(“#destination”).multiselect({multiple: false});
    $(“#country”).multiselect().bind(“multiselectclick”, function( event, ui ){
    $(this).multiselect(“close”);
    $(“#destination”).multiselect(“destroy”);
    $(“#destination”).html(getValues(ui.value));
    $(“#destination”).multiselect({multiple:false});
    });
    })

  • Anonymous

    Hey, good suggestion there; it should definitely work like that. Thanks for the bug report; should be fixed by this commit: https://github.com/ehynds/jquery-ui-multiselect-widget/commit/de5dc55ec8c65ad438347570f65a63eb0ecbbb79

  • http://twitter.com/AugiCZ AugiCZ

    Thank you! Now, the pre-selected value is propagated properly during the widget creation.
    But, when I check some radio then the change is not propagated into label (I’m using “selectedList” option set to “1″). The value is propagated into original “select” properly.

  • Terry

    is there any way to disable/enable or select/deslect an option base on another option?
    i have some options that are mutually exclusive, if it’s checked/unchecked I want others to become disabled/enabled.
    i also have options that are mutually inclusive, if it’s checked/unchecked then i want others to become checked/unchecked.

  • http://twitter.com/AugiCZ AugiCZ

    I investigated the bug more precisely and when I’m in “update” method then “value” is obtained correctly, “this.buttonlabel.html(value);” is called but the new value is not shown :-(

  • Ken Peters

    Hi Eric, thanks for the great widget, love it!

    I came across a chrome-specific bug for the single select mode. When you init the widget, option 2 is selected in firefox, but not in chrome (version 9.0.597.19 on ubuntu 10.04). Also on chrome, selecting a radio button in the widget doesn’t seem to be updating the original select element.

    Option One
    Option Two
    Option Three

    script:
    $(“select”).multiselect({
    multiple: false,
    noneSelectedText: ‘Select One’,
    header: ‘Select One’,
    selectedList: 1
    });

  • Anonymous

    Hey there, yep, I fixed this bug a few weeks ago: https://github.com/ehynds/jquery-ui-multiselect-widget/commit/de5dc55ec8c65ad438347570f65a63eb0ecbbb79

    I’m hoping to release sometime this week or next.

  • Anonymous

    did you grab the full multiselect version on github or just patch that line in whichever version you’re using? I’m almost certain I fixed this one as well. Try the latest from github.

  • Krabats

    How to use setOption method? An example would be beautiful.

  • http://twitter.com/AugiCZ AugiCZ

    The problem was in my page. I had this:
    $(“button”).livequery(function() {
    $(this).button();
    });
    that was the root of all evil – I changes this and all works like a charm ;-)
    Thank you very much for the widget!

  • Dmitrij Petters

    Great Plug-in. One oddity that I’m trying to resolve though. I have the following line in the click event handler – alert($(this).multiselect(“getChecked”).length); With no checkboxes selected, if I click one, the alert gives me 1. However, if I do $(“select”).multiselect(“widget”).find(“:checkbox:eq(2)”).trigger(“click”); instead of clicking, the alert gives me 0. Any idea for what might be causing the discrepancy? Thanks!

  • Never Logon

    Hi! it’s a fantastic plugin!!!
    However I have a doubt… I click the OptGroup heading and all options of the group are checked but then is invoked the _toggleChecked function that is called even with checkAll and uncheckAll. Everything is ok until the last row of this function:
    this.element.find(‘option’).not(‘:disabled’).attr(‘selected’, (flag ? ‘selected’ : ”));
    used to “toggle state on original option tags”.
    The result is that all the options (not even the optgoup ones) are signed as “selected” in the original option tag so if you use something like Struts (as I do) in the back end you’ll find different values checked.
    I’m supposing right?

  • Anonymous

    Upgrade to version 1.8 (released yesterday). Fixed in this commit: https://github.com/ehynds/jquery-ui-multiselect-widget/commit/c2debd31ac3b8883d35ffb24047dcf51262f7238

  • Never Logon

    Really fast answer! :)
    I upgraded and now it works!
    Good work!

  • es

    Great plugin! Is there a way to customize what is displayed when you hover over the check box? Currently it displays the label of the option, but I’d like to customize that to be a description of the option. Thanks!

  • ez

    It appears that the plugin doesn’t work if the page is in xhtml. I get this error (in chrome and FF) on the following line of the plugin (version 1.8)
    line 284: checked: $inputs[0].checked

    –> Uncaught TypeError: Cannot read property ‘checked’ of undefined

    All that I have to do to fix this is change the page to be plain html instead of xhtml and everything works. I’m curious why xhtml has a problem with it, and if it’s easy to fix.

  • Anonymous

    Interesting. Are you actually serving the page with an xhtml mime type, and that’s when it breaks?

  • Iubianz

    i am using as a radio button in search option, but a problem is In fire fox one item must b selected it is optional, how can it’ll be unchecked in default?

  • Anonymous

    Hello Eric,

    Above all, congratulations on your work. After so much time using your plugin on my projects, unfortunately, I noticed that there is a downside …

    After applying the function .multiselect(), I found that I can no longer utilize the function of jQuery, the .live() in tags. Simply does not work… I put the function alert() to popup and… nothing.

    Test yourself and you will see: $ (. “input-multiple-select-widget”). live (“click”, function () {alert (“hello”)});

    What can be?

    I give you a beer (via paypal) if you get hit!

    Thank you, Vinicius – Brazilian.

  • Anonymous

    Hi there,

    you’re trying to bind a live click event to the button that multiselect creates? It sounds like you’re selecting it wrong, because nothing in multiselect prevents other events from firing.

    I suggest using the open/close callbacks instead of binding to the button directly. Clicking on the button will fire these callbacks automatically depending on whether the menu is open or not.

  • Anonymous

    Thanks, man. I using open callback in json directly and it occurred in a desired manner. And “buy me a beer”? you do not? haha.

  • Cosmotheory

    How to use these onchange();

    $(“#widget”).multiselect(‘disabled’,'disabled’);
    $(“#widget”).attr(‘checked’,'checked’);

    Note: if widget is an option id in select?

  • timo

    Hi,
    I’m experiencing the same problem as gdi. Is there anyway to make “check all” to work correctly with the filter?

  • Quetzy

    Yes, the change event should be exposed so I can catch it with jQuery’s .change().

    Keep up the good work! :)

  • Hans Jacobs

    Very nice widget, but when you have very big lists, ie prompts user to stop script. I have over 2000 options. How to handle this? I was thinking about an ajax-request.

    Best regards, Hans

  • Shaniabudi

    I need a string of all the selected values separated with a coma.
    When I use
    var array_of_checked_values = $(“select”).multiselect(“getChecked”).map(function(){
    return this.value;
    });
    in chrome it returns an object so I can’t use array_of_checked_values.join().
    How can I get a string of all the selected values separated with a coma?

    Thanks

  • Anonymous

    You forgot to .get() at the end of the map to extract the actual array out of the jquery object. You can actually do: $(“select”).val().join(“, “); instead though- no need to go through multiselect first.

  • Shaniabudi

    Thank you!
    I just needed to split that code to two lines (in case val() returns null)

    $selected_array = $(“select”).val();
    if($selected_array != null)
    {
    $selected = $selected_arra.join(“,”);
    }

  • David At Sitec

    Hello, I have been trying desperately to center this widget, I can not get it to work, furthermore if I wrap my initial select menu in a div, and try to position the div it does not work at all. When I look at the styling on the widget using firebug, I am finding that the positioning is hard coded into the element, is there anyway to set the styling of the widget so that I can center it, or specify where it should be on the page using css. The only way I have been able to change the placement of the widget is to place center tags around my initial select list.

  • Alex G87

    Hi!! Fantastic jquery applications!
    But i have one question :
    i need to create an for each elements checked and then i have to send all the values of the form.

    Example:
    jquery multiselect: -red CHECKED
    -green
    -blue CHECKED

    and then in another div:

    -red
    -blue

    So i can save in my database RED with check1.value and BLUE with check2.value.

    Help me please….and thanks a lot!

    ALEX

  • Fabien7474

    Hi Eric,

    I am using your great plugin for a while now and I would like to thank you very much for this.

    Regards,

    Fabien

  • Kcnolanjax

    Eric, Awesome plugin. You really have done a phenomenal job with it! One small problem. When using with phpmailerFE (phpmailer.worxware.com), only a single form variable is received by the server. In other words, when the form is submitted, only one of the options is sent in the autoresponder message. Thoughts?

  • Kumar

    Control works great for me. But, Is there a way to make option button grouped? I would like to select one option per optgroup.

    Thanks,
    Kumar

  • Terry

    How do I hide the checkAll/unCheckAll buttons?

  • Scott

    Hi Eric, I love your jquery UI multiselect…I am just playing around with it now…I am integrating it with asp.net…2 Issues i have so far…it seems when the page is first loaded the dropdownlists are fully extended unless I call the “close” method. Unfortunately the page fully displays first and then they are visually seen closing when what I would like is that they are never open to begin with…is there a option I can use to default to closed mode? Also, one dropdownlist contains 1250 items..ie7 complains that the script is slowing down the web page…i have to hit continue 5 or 6 times for the script to completely finish…is there any way to speed this up? By the way I am using the multiselectfilter function in these scenarios…Also, there seems to be a bug that when you filter and then tell it to check/all it seems to be taking a long time as if its going through the whole list instead of just what has been filtered to either check or uncheck all…and of course because there is 1250 items I get the script timeout error numerous times.

    Any help would be greatly appreciated…
    thanks,
    scott

  • http://twitter.com/tworzenieweb Adamczewski

    Hi Eric, brilliant plugin but I try to extend it because when we use optgroups and multiple: false it should select one item from each optgroup but sadly checkbox aren’t attached to optgroups by adding name=”optgroup_name” attr, each checkbox is unique. I try to fix this by myself but there is only one value send by form. So basically do you know how to achieve this?
    Lucas

  • Abe

    Hi Eric,

    I have a quick question… I need the opposite of $(“select”).multiselect(“getChecked”) i.e. I need all the unchecked selecttion…

    I added another property to the multiselect in the jQuery.multiselect.js file

    getUnChecked: function () {
    return this.menu.find(‘input’).not(‘:checked’);
    },

    However, this is never being called when I do something like this…

    var array_of_unchecked_values = $(“#” + id).multiselect(“getUnChecked”).map(function () {
    return this.value;
    }).get();

    Is there anything else I need to do?

  • Anonymous

    No, that should work. Instead try getting the option tags off the original select, like $(‘#” + id).find(‘option:not(:selected))”).val();

  • Anonymous

    Hi Scott, multiselect should never be open by default unless you set the “autoOpen” option to “true”. Perhaps you have some conflicting CSS there that sets the menu “display” to “block”?

    This widget isn’t really meant to handle that many items. Unfortunately when you’re looping that many times around the DOM, things will be pretty slow no matter how you tackle it, especially in IE7.

  • Anonymous

    Set this CSS declaration:

    .ui-multiselect-all, ui-multiselect-none { display:none; }

  • Anonymous

    Thanks! Try naming your select with trailing brackets (e.g, “countries[]” instead of “countries”) so PHP knows to grab multiple values as an array.

  • Anonymous

    Thanks :)

  • Anonymous

    Hi Scott, multiselect should never be open by default unless you set the “autoOpen” option to “true”. Perhaps you have some conflicting CSS there that sets the menu “display” to “block”?

    This widget isn’t really meant to handle that many items. Unfortunately when you’re looping that many times around the DOM, things will be pretty slow no matter how you tackle it, especially in IE7.

  • Anonymous

    Set this CSS declaration:

    .ui-multiselect-all, ui-multiselect-none { display:none; }

  • Anonymous

    Thanks! Try naming your select with trailing brackets (e.g, “countries[]” instead of “countries”) so PHP knows to grab multiple values as an array.

  • Anonymous

    Thanks :)

  • Anonymous

    Hi, the menu is positioned against the button, but the button doesn’t have any positioning by default. You should be able to wrap your original select element in a div or something, center it, which will center the button. Let me know.

  • jim.bob.smith

    Quick question: I’m new to jquery… How would one add Optgroups via a json call..here is what I have now. The options items appear in the dropdown.
    $.each(items, function(index, parent) {
    sEg.append($(“”).attr(“label”, parent.Value));
    $.each(parent.Children, function(index, child) {
    sEg.append($(“”).attr(“value”, child.Value).text(child.Text));
    });
    });
    sEg.multiselect(‘refresh’);

  • Anonymous

    Hi Eric, this is what exactly what I want. you made my day. I need to use filter multiselect, but I stuck here. If I am using multiselect only, it works find. It calls refresh method and close event correctly. But when I have added filter functionality to the page. It stops calling close event and refresh method. can you please help me to understand how to refresh multiselect filter widget (as I need to add options on the fly) and trap close event?

  • Anonymous

    oops, It was my mistake. working fine now. Thanks.

  • Ondrej Klement

    Would it be possible to make every “line” (=item) dragable? so you could change position of every single item in the selectbox? and for example send item’s position by ajax, so it could be stored in the database?

  • HansB

    How can I???? in the header the first two selections are by name if three items selected # of # selected must be used.

  • db

    Very great plugin! I use the “jquery.ui.selectmenu”, which is not yet in the official jquery ui package. I think, this plugin is better and has more functionalities (for instance it support single and multiple selects), save one – it doesn’t support images in options. If it did, this could be published as “jquery.ui.selectmenu” in the official jquery ui package very soon.

  • Damon

    The $(controlSelector).val() and .val(value) methods don’t seem to be checking UI elements like I would have thought.

    Also I noticed that in the click event handler, the .val() result hasn’t been updated yet at the time the click event is called. I learned to use the ui parameter in the event callback to get the new check state, but I think it would be better if val() and val(value) could be used instead. This would mean less porting of event handlers required to switch from a plain old html multiselect to this widget.

  • ShawmutSteve

    Super nice. Any thought to allowing the dropdown menu to be a different width (wider) than the button? I have a bunch of buttons and it would be much easier to make them all consistent looking.

    Thanks !

  • Martin Andersen

    Is it possible to search a single select box? I can not get the filter to work. I have tried many combination’s of input parameters.

    $(“#profiles”)
    .multiselect({
    header: “Vælg en profil”,
    noneSelectedText: ‘Vælg en profil’,
    selectedList: 1,
    multiple: false
    }).multiselectfilter();

    Alle Profiler
    ANDERS SAMUELSEN (7)
    Hund (48)

  • Quetzy

    I achieved that by using the “classes” option. Create two classes, one for the button and anotherfor the list.

    Like this:

    .ui-multiselect-menu.auto { width: auto !important; }
    .ui-multiselect.fixed { width: 140px !important; }

    Then, just pass the classes names to the “classes” options, like this:

    $(“.select”).multiselect({ classes: “auto fixed” });

    Try it.

  • chrispret

    I created a new option for the menu width. Not tested in anything but IE, but the basic idea is that you may want the menu to be wider than the button. Simple enough to implement:
    In options:
    options: {
    header: true,
    height: 175,
    minWidth: 225,
    menuWidth: 0,
    classes: ”,

    In setOption:
    case ‘menuWidth’:
    case ‘minWidth’:
    this.options[key] = parseInt(value, 10);
    this._setButtonWidth();
    this._setMenuWidth();
    break;

    In _setMenuWidth:

    _setMenuWidth: function () {
    var m = this.menu,

    width = this.button.outerWidth() -
    parseInt(m.css(‘padding-left’), 10) -
    parseInt(m.css(‘padding-right’), 10) -
    parseInt(m.css(‘border-right-width’), 10) -
    parseInt(m.css(‘border-left-width’), 10);

    // CP Add: Option to set the width of the dropdown menu
    o = this.options;
    if (o.menuWidth != 0) {
    m.width(o.menuWidth);
    }
    else{
    m.width(width || this.button.outerWidth());
    }
    },

  • chrispret

    Sorry, I forgot to start off with, GREAT WIDGET!!!!

  • chrispret

    I like my solution (posted above) a little better simply because I can easily set the menu width using setPosition when the window is resized etc.

    Of course you can also do that using css, but I can say I like mine better simply because I did it myself :)

    Honestly though, if I found your solution before doing it my way I probably would have gone with yours since it means I can just plug in a new version of the widget when it is updated.

  • http://www.asver.pl Asver

    Hello!
    Thank You for this widget. It’s awesome. My English is not, but I will this post write nonetheless.
    I just encountered some strange behavior in IE7, and sadly reading all Your posts here and there on this topic, and even standing on my head, doesn’t seem to solve the problem.
    Its about adding select element to DOM dynamically and then adding multi-select to it. My script works in FF,Chrome,Opera,IE8 but in IE7 I see only empty list.

    The code is:
    $(‘#’+ID).find(‘.rzadMenu’).html(”);
    var tymczas = ”;
    $.each(TO.kolumny,function(k,v){
    tymczas += ”+v.nazwa+”;
    });
    tymczas += ”;

    $(‘#’+ID).find(‘.rzadMenu’).html($(”+tymczas+”));

    $(‘#’+ID).find(‘.rzadMenu’).find(‘select’).multiselect({
    noneSelectedText: ‘Dodaj filtr’,
    minWidth:130,
    height: 150,
    checkAllText: ‘Zaznacz’,
    uncheckAllText: ‘Odznacz’,
    selectedList: 1,
    header:false,
    multiple:false
    });

    Its strange, because in IE7 HTML code I see my list correctly, but ul created by Your widget is empty… :(
    Any idea what is wrong?

  • http://twitter.com/ewg118 Ethan Gruber

    Hi,
    Great widget, but there is a little thing I can’t figure out. I’d like my noneSelectedText to be dynamic based on the title attribute of the select element. I tried $(this).attr(‘title’), but it gave me the title of the HTML document. How can I get the title of the .multiselect in order to populate noneSelectedText?

    Thanks.

  • http://twitter.com/ewg118 Ethan Gruber

    Hi,
    Great widget, but there is a little thing I can’t figure out. I’d like my noneSelectedText to be dynamic based on the title attribute of the select element. I tried $(this).attr(‘title’), but it gave me the title of the HTML document. How can I get the title of the .multiselect in order to populate noneSelectedText?

    Thanks.

  • Guilherme Tiscoski

    Hello,

    First: Thank you for this widget, It helped me a lot.
    Second: How do I change the widget’s color? It’s orange by default and I coudn’t figure it out.

    Att,

    Guiherme Tiscoski

  • Martin Andersen

    I am VERY frustrated!!! why? I got everything to work in Firefox with filter, styling and custom text.
    But with 890 elements in the list IE7 and IE8 is chucking. The non responsive JavaScript dialog keeps popping up.
    Can I do something to speed it UP? tweak the code or specialize it somehow.

    Hope to get some help or maybe some god ideas

  • http://twitter.com/ewg118 Ethan Gruber

    I found a solution–
    create: function(){ $.ech.multiselect.prototype.options.noneSelectedText = $(this).attr(‘title’) }
    It may or may not be the most elegant or efficient solution. I’m not sure.

  • http://twitter.com/ewg118 Ethan Gruber

    Hrm, actually, this sets the noneSelectedText of the the next .multiselect with the title attribute of the current one.

  • chrispret

    CSS is your friend

  • Anonymous

    Is there a way to set a max limit for “Select All”? I have a select option that has over 800 entries, I would like to limit select all to 50, when they click select all.

  • Anonymous

    From the demos…

    Refresh Method

    Calling refresh allows you to re-build the multiselect menu from your original select. This is useful when the contents of the select box changes dynamically (through either AJAX, DOM manipulation, etc.) and you want the multiselect widget to reflect the changes.

    // once the “add” button is clicked below:
    $(“select”).multiselect(‘refresh’);

  • Todd

    After adding the filter plugin these now gives me a script loading error in IE and locks up … however in other browsers works fine. The multiselect has over 700 options

  • Martin Andersen

    Yes the javascript engine in IE is very SLOW. I am facing the same problem. Everything works in none IE browser. My solution is to only start the search if the input length is >= 2 and delay the keyup event for 400 ms.

    some test code

    $(‘#filterAuthors’).keyup(function (event) {
    event.preventDefault();
    clearTimeout($.data(this, ‘timer’));
    var wait = setTimeout(function () { listFilter($(‘#filterAuthors’), $(‘#authors’)) }, 500);
    $(this).data(‘timer’, wait);
    });

    function listFilter(input, list) { // header is any element, list is an unordered list
    var filter = $(input).val();
    if (filter && filter.length >= 2) {
    // this finds all links in a list that contain the input,
    // and hide the ones not containing the input while showing the ones that do
    $(list).find(“li:not(:ContainsNoCase(” + filter + “))”).hide(); // slideUp(“fast”);
    $(list).find(“li:ContainsNoCase(” + filter + “)”).show(); // slideDown(“fast”);
    console.log(“searching”);
    } else if (filter == ” || filter == null) {
    $(list).find(“li”).show();
    }
    }

    It’s far from perfect but now I can search for around 1000 items in IE

    The creating of the list can get a speed burst if the entire list is build as string and then attached to the dom.

  • Alon

    HI, can you help us solve a safari iphone issue, we can not see a scrollbar, only height with big number can solve the problem and present all data.
    Thanks

  • Chuck

    Eric, great job! I am an old hand at php but a newbie at jquery/javascripting. I got multiselect working but have a couple of questions. First, I have four selects in a form and I want to change the text (“Select option”) on each one to reflect what the use is selecting. I have tried several different ways to do this, here is the latest:
    $(function(){
    $(“select”).multiselect({minWidth:150}).multiselectfilter();
    $(“select[name=styles]“).multiselect(“option”,”selectedText”, “Select Styles”);
    $(“select[name=types]“).multiselect(“option”,”selectedText”, “Select Types”);
    $(“select[name=colors]“).multiselect(“option”,”selectedText”, “Select Colors”);
    $(“select[name=uses]“).multiselect(“option”,”selectedText”, “Select Uses”);
    });

    This doesn’t work. Any ideas how I can accomplish this?

    I have also been trying to figure out how to trigger the onchange event only after the open select box is closed. I have no idea how that or if that is even possible. Thoughts?

  • Matt Wright

    I’m having some trouble with tabindex. Not sure if anyone else has had trouble with this, but on my page I have a text field with an index of 29, then my with an index of 30, then another select with an index of 31, then another text field with an index of 32.

    When I click into the first text field and hit tab, it misses the two select boxes entirely and jumps down to the 2nd text box. If I remove the multi select the tabbing works perfectly. Any ideas what’s going on?

  • http://twitter.com/ptaczek Zdenek Neuman

    Hi, thanks for briliant work! I came across a following problem: When the menu is closed by ESC key and there is a handler of “close” event, then any AJAX request called from the handler is aborted by the ESC, resulting in no response being received in FireFox. Is there any clean solution to this problem instead of modifying the source (which works by adding e.preventDefault in the this.menu.delegate “keydown.multiselect” handler) ?

  • emdie

    Hello,
    I have an error in the following sequence (creating the widget). “$[namespace] is undefined”

    // create widget constructor
    $[namespace][name] = function(element, options) {
    var self = this;

    Any Ideas?

    Thanks

  • Humberto

    Is there any way to get the multiple selected text?

  • Siim

    Hello, nice widget, haven’t seen a better multiple select.
    Is there a simple way to display background of checked items with different color?

  • Knusul

    How to enable filering by optgroup? f.e. When I have optgroup seat with opts ibiza, leon, when I type to filter seat I want to see ibiza and leon, and when i type leon i want to see leon

  • Andreas

    Hi Eric

    What a great and versatile plugin.

    I have scenario where I would like to structure the elements with optgroups. I think it would be beneficial if the optgroups (header and children) could be visualized in separate columns, instead of the one column structure presented in the demos – i.e. a sort of multiselect megamenu.

    Have you thought about adding this kind of functionality to the plugin?

    /Andreas

  • dante_swang

    Hey Eric Amazing Plugin Sir, really well done. Question i have some dynamic selects which render on the page. I am attaching your plugin this way $(‘select’).multiselect(); How would i attach validation to them such that atlest one of checkboxes is selects for each instance ?

    below doesnt seem to be working. (where DD_PREFIX + ddId is the id of the dynamically created select)

    $(DD_PREFIX + ddId).rules(“add”, {
    required: true,
    minlength: 2,
    messages: {
    required: “please select at lest one reason”,
    minlength: jQuery.format(“Please, at least {0} characters are necessary”)
    }
    });

  • Anonymous

    Hi, see this fiddle: http://jsfiddle.net/ehynds/Y3k4X/

    I’m definitely going to simplify that process though; too much work for something so simple.

  • Anonymous
    $('button.ui-multiselect').text()
  • Anonymous

    What version of jQuery UI are you using? Looks like you have a conflict going on; maybe you’re trying to use this on jQuery UI 1.7? (requires 1.8)

  • Anonymous
  • Anonymous

    Yeah, the button isn’t inheriting the tab index. I’ll open a ticket for this. Thanks!

  • Anonymous

    Yeah multiselect isn’t really designed to work with that many elements. Not sure you’d want your users to scroll through a list that big; bad UX.

  • http://thecodeninja.net Abdul Mueid

    give your select tag an id attribute with brackets like:

    id=”names[]”

    In PHP, your post variable should now contain an array named multiselect_names with the selected values.

  • Andrew

    So I saw people’s earlier comments on “check all” button not working with the filter plug. You can reproduce this odd behavior on the demo page. If you click on ‘Blue’ in the drop down than filter on the word ‘Red’ the widget will say 1 selected. Press “Check All”, the widget will say “2 selected” with Red and Blue showing check boxes if you clear the filter. If you check the value with jquery, you will see that all of the elements are selected. Has anyone found a work around?

  • Amos Vanhorn

    I am using ASP.NET MVC and having the same problem – the original select gets removed from the form or something

  • Andreas

    Hi Andrew,

    I’ve just updated the corresponding bug report: https://github.com/ehynds/jquery-ui-multiselect-widget/issues/#issue/48

    It looks like the “checked” values of the original select are not updated if one users the filter in combination with “check all”.

    Have a good evening
    Andreas

  • http://ethanwoo.wordpress.com/ ethanwoo

    hello Eric Hynds, i find a bug . if you use :

    $(“select”).multiselect({
    selectedList: 1,
    multiple: false
    ).multiselectfilter();
    desc: if set multiple :false ,the filter input can not see !!!
    beacuse : .ui-multiselect-single input { position:absolute !important; top: auto !important; left:-9999px; }

    SO: I change the jquery.multiselect.js: begin Line 85 end 98, MY CODE:
    checkboxContainer = (this.checkboxContainer = $(”)).addClass(‘ui-multiselect-checkboxes ui-helper-reset’);
    if (!o.multiple) {
    checkboxContainer.addClass(‘ui-multiselect-single’);
    }
    checkboxContainer.appendTo(menu);
    this._bindEvents();
    this.refresh(true);

  • Anonymous

    Hi Eric,
    Amazing plugin! It’s a lifesaver!

    I am however getting a 405 method not allowed error when clicking on the “check all” and “un check all” links inside the widget header. This causes my app to continuously show 405 method not allowed errors in firebug as it reloads all external .js files.

    Using a live query (below) to remove the href attribute from the links in the widget’s header I can prevent this odd behavior and finally get firebug to show me something to go with.
    $(“a.ui-multicheck-all, a.ui-multicheck-none”).livequery(function(){
    $(this).removeAttr(‘href’).css(‘cursor’,'pointer’);
    });

    Firebug renders the following error:
    uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]” nsresult: “0×80070057 (NS_ERROR_ILLEGAL_VALUE)” location: “JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js :: anonymous :: line 5910″ data: no] Line 0

    After researching this (and as the error shows) it appears to be an issue of passing an illegal/null value to the underlying XMLHttpRequest.open method. Using Chrome’s Inspector and IE 9 developer panel this is the line in jQuery that it was alerting me as to where the problem was occurring, whereas firebug was failing to do so before I put in place the above livequery() to manually remove the href=”#” which seemingly was the culprit.

    Could there be a silent JS error (that firebug isn’t showing) that could trigger such a behavior?? I have used JSLint on the code causing the error and it didn’t find anything of concern so I am stumped after hours and hours of possible workarounds.

    Any ideas as to how I could possibly prevent this behavior would be much appreciated.

    Thanks,
    Tim

  • http://chair9design.com Tim Brown

    you could try putting the rules as metadata on the select directly.

    http://jquery.bassistance.de/validate/demo/custom-messages-metadata-demo.html

    This usually works well for us as we deal with a lot of dynamic forms.

  • http://twitter.com/jasonedelman Jason Edelman

    Feature request: an “isDirty” property that updates to “true” any time the existing state of the multiselect is changed and is accessible in the “close” method. Maybe create a “beforeOpen” method that resets “isDirty” to false, or somehow have a method after “close” that resets it.

  • http://twitter.com/almostonline Sergiy Andrusenko

    Hi All!
    I have a some bug in Opera browser
    (Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.7.62 Version/11.01).

    See this bug on demo page, for example
    http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/
    Bug Step are:
    1) open demo page in Opera browser
    2) click some multyple controls
    3) press “tab” button

    Opera is crashed…

    Any ideas as to fix this bug?

    TNX. Serge.

  • Anonymous

    Hi

    Great stuff! Epic even :)

    Maybe you’ve already explained this somewhere, but my page has six multiselects (not many options on them). After the page has loaded you can see them as standard html multiselects, before the js “kicks in” and transforms them (0.16 seconds perhaps, enough to see it). Is there any way of having it “kick in” sooner or faster? I’m using the multiselect function in document ready function, and the page they’re used on is an iframe within a joomla installation.

    Thanx a bunch for this very cool stuff!

  • Anonymous

    I’m having an issue with multiselect-all, muliselect-none, multselect-close. When clicking on those nothing happens. Does anyone know what the issue could be?

    using jquery-1.4.4.js and jquery-ui-1.8.2.custom.css

    Thanks

  • http://profiles.google.com/sailorh Jeff V.

    When using multiple:false is it possible to for the selected element to be displayed when the user clicks the dropdown? Right now it simply shows the top of the list when you click the dropdown, if you have more than a few items in the list the user has to scroll to see what is selected.

  • Irck

    Nice plugin, but it seems to block the browser on load when trying to init with over 1000 entries in the options list..

    Is there a way to fix this?

  • Anonymous

    You can do this with the jQuery UI position utility, which multiselect has support for. See the demos page for details.

  • Anonymous

    This makes a lot of sense. I’ll work on it when I can.

  • Anonymous
  • Anonymous

    The fastest way to make them kick in is to init them one at a time directly after the select element, not in a document.ready. Obviously, this opens the door to a maintenance nightmare and bad practice. Other than that, I’m sorry to say you’re at the mercy of document.ready :/

  • Anonymous

    Thank you, I have landed this change.

  • Anonymous
  • Anonymous

    Yeah it’s possible. there was a bug that prevented the search text input from showing up in single select mode, which has been fixed and will be available in a release shortly.

  • Tim

    Hello,

    Great great work !
    However, I am using a multiselect which values are refreshed through an AJAX request.
    When I am receiving the result of the AJAX (in the success)
    - I am then constructing the string for the select with the new options; ex: var new_select_tag = ‘opt1opt2′;
    - then I am replacing the old one by the new one: document.gelementById(“td_tag”).innerHTML = new_select_tag;
    - and finally I am reinitializing the multiselect: $(#list).multiselect();

    Graphically everything is fine: I have the new values in the select tag, with the correct options checked but when I am sending the form it does not transferred the data of the new select whereas it is doing it correctly when the select was not updated before the AJAX.
    In the code generated I can see that the ‘selected=”selected”‘ of the option does not appear, same for the ‘checked=”checked”‘ of the checkbox; the check only appears because of the ‘aria-selected=”true”‘

    I tried different solutions: using a ‘destroy’ and then a ‘refresh’ but I now I am desperate.

    Can you please help me or even better to put an example to help also the others as I think this is a basic need that many users are looking after.

    Many thanks.

  • http://profiles.google.com/slayer35 slayer slayer

    Hi.Thanks for your usefull code. I want to put a asp.net button into container when the dropdownlist checklist container opens but i cant figure it out.Is there any property that will help me to put a button inside the hover container. Any help is appreciated,thanks.

  • Red Paint

    Hi,

    Great plugin, it’s very very useful. One question: is it possible in a similar way to $(“button”).multiselect(“widget”) to get the id of the button (assuming multiple multiselect’s on a page).

    Something like $(“#multiselect_id1″).multiselect(“widget”) but selecting the button and not the widget?

    Thanks

  • Red Paint

    I’m using $(“#multiselect_id1″).multiselect().next() for now.

  • http://twitter.com/danregazzi Dan Regazzi

    iPhone and Android browsers do not show scrollbars. There are some javascript solutions out there that partially work, but not very well especially for Android.

    The best thing I have found is that iPhone and Android do not need this plug-in. They have a similar implementation built-in to their browser that shows a multiselect as a drop down and when you open it the browser takes over and shows you the content in a popup message window with a built-in scrollbar.

    You can easily test if the user is on a mobile touchscreen browser with

    if( is_touch_device() ) { … }

    function is_touch_device() {
    try {
    document.createEvent(“TouchEvent”);
    return true;
    } catch (err) {
    return false;
    }
    }

  • Vincent Kollin

    Thank you for the incredible peace of code!

  • http://www.raghibsuleman.com/ raghibsuleman

    Thanks for sharing…

  • Anonymous

    Eric – great work on the multiselect widget – it has been very useful for my application. I replaced a different plugin with this one because of the multiple checkbox capability. Everything works great on all browsers except for Firefox. I am having a problem with calling the refresh method on multiple multiselect widgets in succession. It is causing sections of my page to flash white. I have found that if I delay each successive refresh call by calling it within a SetTimeout function (each having a longer timeout), the problem goes away if they fire about 50ms apart.

    I am using the widgets within a themed jQueryUI Tab page. I originally had them as table data, but tried taking them out of the table and moving them to their own DIV container. That appears to have effected what flashes – what I see is a block at the top of the screen, which almost looks like a short text message is being displayed (which I don’t see – it’s just a white flash), and the DIV container flashes. I really don’t want to keep the delays in place, but I haven’t been able to figure out why this is happening. I’d love to hear any ideas on why this might be happening.

  • Anonymous

    Yeah that’s the best way – $(“#multiselect_id1″).next() or $(“#multiselect_id1″).multiselect(“widget”).prev()

  • Anonymous

    I re-factored the create logic in this commit: https://github.com/ehynds/jquery-ui-multiselect-widget/commit/abfd159ab4ccc660263fd58a885e0f682dc74767

    It should be much faster now, especially in IE. 1000 options for this widget is a lot, I’m not sure i’d recommend that as it’ll lead to bad UX… IE might still give you trouble with that many options, so you may need to refactor the commit above to chunk the process in a recursive setTimeout call.

  • http://twitter.com/dnorthut David North

    Eric,

    Thanks for such a great widget. It’s got a great interface and functions exactly how we need.

  • Anonymous

    Love the widget, but I’d like to suggest a minor enhancement. You have noneSelectedText option. For my use, I added allSelectedText option. I was using the ‘n of m Selected’ capability, but did not like how it said ’30 of 30 selected’. Now I can say ‘All items selected’. I’ll bet this would get used a lot.

    BTW – Still hoping to hear from someone who’s experienced the flashing problem in Firefox.

  • Laurens

    I’d like this too. Having the widget show “34 of 34 items selected” is kind of useless, since a user wants to know if they’ve selected all of them or not. So in case of all items selected, such a string would be more appropriate imho.

  • Lance

    I need to do a dependent dropdown list with multiple selections checkboxes. I need the first dropdown to be for states where only one state can be chosen and then the second dropdown is for counties where multiple counties can be selected. Can this be done with this widget or with the Related Selects?

  • http://profiles.google.com/bhogsett Bill Hogsett

    I want to load the select options dynamically from an ajax call.

    This does not work:

    $(“#example”)
    .multiselect({
    noneSelectedText: ‘Select Year(s)’,
    selectedList: 11 // ) based on 0 based index
    })
    .ajaxAddOption(“selectbox.php”)
    .multiselect(“refresh”)
    .multiselect(“uncheckAll”);’

    But if I create a function and call it on a button click, it works with this function:

    function addoptions()
    {
    $(“#example”).ajaxAddOption(“selectbox.php”)
    .multiselect(“refresh”)
    .multiselect(“uncheckAll”);

    }

    The ajaxAddOptions call is from the selectBox plugin and returns json that is parsed and added to the element.

    Any suggestions?

    Bill

  • Laurens

    B.t.w. khoney, after reading your comment again, it seems as if you’ve programmed such an enhancement yourself already? Care to share it with us?

  • http://profiles.google.com/bhogsett Bill Hogsett

    Well, I don’t have an answer to my request, but I have some interesting information.

    I downloaded 1.10pre and looked at the refresh function. At first I thought it was the test for init at the end, but that doesn’t seem to be it.

    So I set out to hack refresh. I began by adding an alert at the beginning of refresh to make sure the function was in fact being called. So the code is:

    refresh: function( init ){
    alert (“Well we made it”);
    var el = this.element,
    etc.

    And guess what! It works! The ajaxAddOptions select options items are added in to the menu during the document.ready function.

    My guess is that the ajax call is not being completed before the refresh and the alert allows it to complete. BUT the button click with the same ajax function works. So I really am not sure.

    Eric, any suggestions about how to get the refresh to work during the document.ready stage? Please.

    Bill

  • Anonymous

    khoney & Laurens, this can easily be accomplished by passing a function to the selectedText option. See this demo: http://jsfiddle.net/ehynds/EVqej/

  • http://profiles.google.com/bhogsett Bill Hogsett

    Eric, I have got refresh working, but I really would really like your view if this is the way it should be done.

    In the document.ready function I have:

    $(“#years”).bind(“multiselectopen”, function(event, ui){

    $(“#years”).multiselect(“refresh”);}

    The refresh is after the ajax call has added the select options to years.

    Bill

  • Heather Smith

    Is it possible to have the filter and uncheckall but not the checkall in the header?

  • http://twitter.com/used2could Brian Young

    There are a few bugs mainly the un/check all buttons when using the the newest jQuery release (1.6).

  • http://www.thedigitalorchard.ca/ Ted Wood

    Oddly, (with jQuery 1.6) when de-selecting checkboxes, they don’t get removed from the select element’s selected options…. is this a known issue? I’m not doing anything fancy, just a very basic implementation.

  • dq

    Can you include the filter in the header but not the check all and uncheck all buttons?

  • Anonymous

    is there a way to keep the control open and make sure it remains open??

    I know there is a way to autoOpen the control so it is open while the page is loaded but i am looking into a way to disable or remove the link to hide the control so its always open.

  • heather smith

    yes, but apparently you cannot have the filter and uncheck all. Which is too bad because I don’t want users selecting 200+ neighborhoods, but I do want them to be able to uncheck all of them and use the filter.

  • http://twitter.com/iamtwit Vladas Freimanas

    yes @twitter-15755582:disqus that would rock!
    a lot of times I am checking if data has changed from beforeOpen to beforeClose, so I know something was changed and lets say need to call .post to update server side data.

    So this would be a good thing to have: if(isDirty) do whatever needs to be done, because there were changes.

  • Rainer Mueller

    Hi Eric,

    a really great plugin, we use it extensively in our application.

    We have a different behaviour using Safari browser. The second click on ‘Select options’ text or ‘Open/Close’ icon does not close the MultiSelect widget.

    Is
    anyone else having
    this problem?

    Thanks,

    Rainer

  • Rainer Mueller

    Sorry, should check the issues list first. Already fixed with #68, works for me!

  • Nonos

    Great widget !

    Here is a patch to display an icon near the checkboxes :

    in refresh (line 116) :
    var iconURL = $this.attr(‘iconURL’);

    // add the title and close everything off
    html.push(‘ />’ + (iconURL ? ” : ”) + title + ”);

    and the HTML :
    Option 1

    Thanks,
    Nonos

  • dolly

    Hello Eric,

    I am facing problem by using multiselct plugin. Does it have sort feature by default?
    My scenario:

    In my application i am using multiselect control on top of my select box.  I have “SABIC”, “Santa”,”SET” in my select box. Actually, the above order is the correct one. But, it is displaying all uppercase first and then the lowercase like “SABIC”, “SET”, “Santa”. I am not sure of what is going on. Please, any help would be greatly appreciated.

  • Anonymous

    Multiselect doesn’t sort at all.  It loops through the option tags as they are present in the HTML.

  • Anonymous

     Thanks, I agree.  This should be customizable.

  • Anonymous

     Yep, fixed.  Upgrade to multiselect 1.10.

  • Anonymous

    This is one of those options that can’t be changed dynamically :)  The simple solution is to destroy the widget via multiselect('destroy'), then re-init it as a single select.

  • Anonymous

    This has been fixed in version 1.10. 

  • Anonymous

    Bill, this sounds like an AJAX race condition.  My guess is that the “ajaxAddOption()” method hasn’t completed it’s task before you’re calling

    multiselect('refresh')

    on the select box.  Does addAjaxOption have a callback you can attach to, so you can fire the refresh after the options have been inserted into the DOM?

  • Zib

    Really nice plugin, helps a lot :)
    Is it possible to set locales in the same way the datepicker (for example) plugin does ?$.datepicker.regional['en'] = {
    closeText: ‘Done’,
    prevText: ‘Prev’,…};

  • Alex Kalderimis

    Just a note that the instructions are incorrect: the method name for changing an option value should be “option” not ‘setOption’ (see the UI Widget Factory docs). So the following code works:

    > $(‘#divid’).multiselect(‘option’, ‘noneSelectedText’, ‘Foo’);

    But this will not:

    > $(‘#divid’).multiselect(‘setOption’, ‘noneSelectedText’, ‘Foo’);

  • Neobahamut20

    Suggestion:
    Add class to label when it is selected. It kinda works with single select boxes, but for the multiselect there is no way to change the formatting for a selected item.

  • Frank

    Is there any sorting functionality in your plugin, or plans to add it? At the moment I am using an array to hold values I dynamically add, sort this array and then add to the multiselect. Not a big deal but a built in sort method would be nice.

  • Anonymous

    This is very useful.
    Any plans for server side support?  Using the runat=”server” property seems to be not supported.

  • Tim

    Hello Eric,

    I am coming back once again with the same question of last week because you didn’t publish it:
    Is there a way to hide the “normal” select tags if there are some behind when you are expending the div of you plugin to show the options available in IE6.
    You can answer me in MP as I put this time a valid email address.

    Thanks a lot by advance, it will really help me.

  • W S

    Hi Eric,

    Thanks for the very nice plugin. I’m sure I searched this thread for solutions and seems nobody raised it before. When using muttiple false, is there a way to have filter capability?

  • W S

    Hi,

    This seemed to have been fixed on issue #69. Thanks

  • http://haes.myopenid.com/ Haes

    Is there a way to limit the width of the button element only?
    I’d like the button to fit into my small area, once the menu is open I don’t care if its width is getting larger.Adding a fixed width using css doesn’t seem to work.

  • Andreas
  • SteveB

    Couple of questions…
    1. is there a way to retrieve current widget configuration, e.g. {header:true,selectedList:4,…}
    2. upon refresh, is the configuration reset?

    If configuration is reset on refresh, then (1) would allow a widget to be resetto its original configuration after a refresh

  • Alberto Basile

    Hi, I love your plugin … widget, sorry ;-)
    I am struggling to select an element from the list.
    Basically I preload my multiselect when the page is complete and they I do some ajax call and I use the answer to choose the element in the list.
    I’ve tried this code:
    $(“#ProductCategory option[value='3']“).attr(‘selected’, ‘selected’);

    but it doesn’t work. I’ve tried different things but it I can’t achieve what I want.
    Any help will be appreciated :-)
    Alberto

  • Dalia

    Hello Sir,
    Great plugin and nice coding.
    Is the original “onChange” event implemented?. If not how to implement it. can this be added
    to the plugin.
    Thank you 

  • Vol7ron Forum

    Curious if you might patch this to include a mixture of checkboxes and radio buttons.  For instance, say your dropdown will be for a car.  One group might be for the exterior color (black,red,white..etc), and another might be for transmission (auto/manual).  Well, for whatever reason, if you only want users to look up one transmission type at a time, but allow them to select multiple colors, then you’d need a combination of checkboxes/radio buttons for the option group.

    I haven’t looked at your plugin in too much detail, but I didn’t see it above – I only saw it could either be checkboxes, or radio, but not a mixture.

  • http://twitter.com/ChrisCinelli ChrisCinelli

    Same need here… What I need is a few collapsable filters.
    I think I will use something else. Patching the code does not sound very viable.

  • http://twitter.com/Ultimedia Maarten Bressinck

    Don’t know if it has been posted but you can use this code to show the selected items within the selectedText field. It works well for me because my multiselect field is quite wide.

    $(“.mutliSelect”).bind(“multiselectclick”, function(event, ui){
    // get the checked values
    var checkedValues = $(event.currentTarget).parent().find(‘.mutliSelect’).multiselect(“getChecked”).map(function(){
    return this.value;
    }).get();

    // set the selected values
    $(event.currentTarget).multiselect(‘option’, ‘selectedText’, checkedValues.toString());
    });

  • Hellspawn

    A quick and dirty way to explicitly set the width of the button and not affect the menu. Just underneath your call to the multiselect constructor:

    setTimeout(function() {
               $(‘button.ui-multiselect’).width(200);
               },15);

    We had to set a timeout here to wait long enough for all the timeouts in the jquery.multiselect.js file to expire before we’re able to manipulate the ‘button’ elements attributes…

  • Anonymous

    Hello Eric, it is a wonderful plugin, thanks very much. I am tried to play around with your plugin and got stuck with a problem in Google Chrome.
    When i click on multiselect/single select, it is creating empty space to its right end moving everything on its right end away.

    Here is the test page http://160.36.179.205/approachthree/.
    Could any one of you help me figure out what could be creating empty right end space with “onClick” event?

    Thanks,
    Ven

  • Hannes

    Awesome plugin! Thanks a lot!

    The only thing I miss is an option to put the header at the bottom instead of at the top. I think putting it at the bottom would make it more user-friendly because it would look more similar to a traditional drop-down menu and feel less cluttered.

  • Hannes

    Awesome plugin! Thanks a lot!

    The only thing I miss is an option to put the header at the bottom instead of at the top. I think putting it at the bottom would make it more user-friendly because it would look more similar to a traditional drop-down menu and feel less cluttered.

  • Hannes

    Awesome plugin! Thanks a lot!

    The only thing I miss is an option to put the header at the bottom instead of at the top. I think putting it at the bottom would make it more user-friendly because it would look more similar to a traditional drop-down menu and feel less cluttered.

  • mauser

    using version 1.10
    have multiple instances on a single page, with optgroup and without, whenever the refresh method is called on any of them, every multiselect with optgroup loses its grouping.

    Nice plugin though, hope this get addressed soon.

  • Johannes Friedrich

    Hey Eric,

    just wrote a litte additional function for your widget. Needed to reselect/update the widget without it beeing rebuild (“refresh”). So if you got a lot of entries, need performance and you change something directly on the selectbox you can run (“reselect”). Fairly simple, but performance optimized.

        reselect: function(){
             var self = this;
                
            // Reselect multiselect
            this.element.find(‘option’).each(function( i ){
                 var isSelected = this.selected;
                 // selected?
                if( isSelected ){
                    $(self.labels[i]).children(‘input’).attr(‘checked’, ‘checked’).attr(‘aria-selected’, true);
                }
                else {
                    $(self.labels[i]).children(‘input’).removeAttr(‘checked’).removeAttr(‘aria-selected’);
                }
            });
       
            this.update();
        },

    Maybe you want to get it in the widget :)

  • pipiet amin

    I have the same problem but already solved, I’ve changed file jquerymultiselect.js to disable close function and it’s work for me. i dont know if this is a good way.

  • Kal_1983uk

    Hi, excellent work. 

    I am having difficulty in retrieving selected items using getChecked via a change event. Soon as the list loads I can get output but not when I start select individual items.

    var branchid = [];

    $(‘#branchid’) .multiselect({ noneSelectedText:”None selected, please select”, selectedText:function(numChecked, numTotal, checkedInputs){ if(numChecked==numTotal) return “All selected”; else return numChecked+” of “+numTotal+” selected”; } }) .change(function(){ getBranch(); });

    function getBranch(){ branchid = $(“#branchid”).mselect(“getChecked”).map(function(){   return this.value; }).get(); console.log(branchid);}

    Any help would be great. Thanks

  • psully1876

    Awesome control, wondering if anyone has run into a situation where for some reason all the options get aligned to the right of the drop down area, having a hard time getting them to align:left

  • Dalia

    Hello Eric, is there a way to add a feature to auto detect the original selection attr
    multiple=”multiple” without having to set it in the plugin options, consider the case where you want to apply the plugin to the the site for both the single and multiple like:$(‘select).multiselect().Another feature is to consider the option for setting the width automaticallyof each select on the page based on the lenght of the select options sayfor example by setting the label to nowrap.Thanks

  • Dalia

    Hello Eric,
    Can you please tell me how to cancel the text bold on hover, when you hover the selected item stretches because the bold effect and if the text is long it wraps to next line and get messy. Thanks

  • ehsan hafeez

    Hi There,
    I am using multiselect in my page. and i want to select two options on open. how can i achieve this functionality. thanks

  • http://twitter.com/regisabino Regis Silva

    I had 2 suggestions in css ->

    ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent;padding:5px;padding-left: 20px; text-indent: -15px; }
    .ui-multiselect-checkboxes label input { outline:none;width: 13px; height: 13px; padding: 0; margin:0; margin-right: 5px; vertical-align: bottom; position: relative; top: -1px; *overflow: hidden; }

    Add class ui-state-default in ui-multiselect-optgroup-label and let css – >
    .ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; background: none; border-width: 0 0 1px 0; }

    I hope you appreciate.

  • Anonymous

    Give the options tags the selected attribute.

  • Anonymous

    Override the jQuery UI theme:

    .ui-multiselect-checkboxes label.ui-state-hover { font-weight:normal; }

  • Anonymous

    Yes, I agree. I’ll tackle these.

  • Anonymous

    Yeah, multiselect doesn’t fire the change event on the select box right now. This is something I’m looking to implement. You can bind to the click, checkAll, and uncheckAll events for now though.

  • Anonymous

    Can you provide a working test case? it’s working for me: http://jsfiddle.net/ehynds/rRqFk/

  • Anonymous

    Hi, I addressed this here: https://github.com/ehynds/jquery-ui-multiselect-widget/issues/110

  • Anonymous

    This functionality is built into the widget. Set the “selectedList” option to the number you want to show, before falling back to a count.

  • Anonymous

    I agree, it is not now but I plan to implement this ASAP.

  • Anonymous

    Configuration is not reset on refresh, just the menu is re-built. You can retrieve configuration options via $(“select”).multiselect(“option”, “option_name”);

  • Anonymous

    yep, sorry about that :)

  • Anonymous

    Thanks, fixed. Sorry about that.

  • Eddie Shipman

    Getting this error:
    $.widget is not a function
    jquery.multiselect.js Line 576

    Not exactly sure why.

  • Eddie Shipman

    Got to include jquery-ui js file, DUH!!!

  • http://twitter.com/jan_db Jan den Besten

    Nice plugin!
    I’ve added a extra option myself: join.
    This is used to set the delimiter string in the field (standard it was hard coded as ‘, ‘).
    Maybe it’s an idea to put this in you’re next release?

    Cheers
    - Jan den Besten

    // Change this in the default options (line 44)

            position: {},
            join:’ , ‘ // Added, make sure you have a new comma in line above
        },

    // Change this at line 216 (update function)

                } else if( /d/.test(o.selectedList) && o.selectedList > 0 && numChecked <= o.selectedList){
                    value = $checked.map(function(){ return this.title; }).get().join(o.join); // Changed ', ' with o.join
                } else {
                    value = o.selectedText.replace('#', numChecked).replace('#', $inputs.length);

  • http://twitter.com/ludoonweb Ludovic Evrard

    Hi, it’s really great plugin! Thanks you

  • Anonymous

    Hi, great widget. Question, while using the jquery form validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/), the issue I’m having is the validation plugin attaches itself to the original select object, so when the validation plugin generates the default error message on validation, that message is to the right of the original element, but to the left of the new multiselect element (so its on the wrong side compared to the text boxes). Anyone know if there is an easy way to fix this, I’ve tried lots of different things with css & the validation plugin, but I’m hoping there is some simple solution I just don’t know about (and keep all error messages to the right of the elements).
    thks,
    Phil  

  • Jorge Ruiz Aquino

    How can I show the select expanded? Like a multiselects select… We need to show the select expanded and not must do click so expand it. Thanks.

  • paulo alvarado

    Does this support adding selectc boxes dynamically ? , because im trying to use this to show options created by a dynamic select box, but once i add a new select box, the old one stops working

  • Eddie Shipman

    How to check if the control is enabled?

  • Eddie Shipman

    Added this enabled() function above the enable function()

      enabled: function() {
        if(this.button.hasClass(‘ui-state-disabled’)) {
          return false;
        } else {
          return true;
        }
      },
     
        enable: function(){
            this._toggleDisabled(false);
        },

    Usage:
    if($(“.multisel”).multiselect(“enabled”)) {
      .. do whatever
    }

  • Msinaysky

    Eric,

    Is it possible to populate control with options manually trough JavaScript. I have a form where I need populate multiselect control with options repending waht has been selected in another control. Regular jQuery ‘addOption’ method does not work.

    Thanks

    Michael Sinaysky

    P.S. It also would be beneficial if you can publish example to do the same trough Ajax call

  • Johan Vosloo

    I use the errorPlacement argument, e.g.:

    errorPlacement: function(error, element) {         if (element.parent().children(‘.ui-multiselect:first’).length) {            error.insertAfter(element.parent().children(‘.ui-multiselect:first’));                   } else {           error.insertAfter(element);        }    }

  • Vincent Legendre

    Hi,

    I had a problem while using both multiselect with optgroup and filter, with my select options filled from AJAX : the optgroup are not displayed until I click in the filter input field.

    The main goal was to populate a select’s options (the multiselect with optgroup and filter) with values dependant of another field. So at init, the list is empty. When the dependant input is set to a value, an AJAX query fills the options and refresh the multiselect, with optgroup and options tags.
    The problem is that when opening the new list (ie not filtered), no groups appears. But if I click in the filter’s input, then the group appears (with all values)… and stay there for further openings … and when I enter something in the filter, groups disappears again.

    I think that the problem comes from the filter plugin, which hide/show groups at end of its “_handler” method. When I comment all this end, groups are always displayed. Thus filtering can then display empty groups (which is not a problem for me, it is even the opposite).

  • codeulike

    As far as I can tell, the “check all” event seems to be all lower case (“checkall”) rather than camel case as in your documentaion. Great widget though, cheers.

  • phoenicoperu

    Is there a way to sort my dropdown list elements created with multiselect plugin? any hacks to do it? Thank you very much in advance

  • Ashish K Kataria

    Hi,

    You can also trigger click event on filter input box on open of select box i.e

    $(“select”).multiselect({               
          open: function(event, ui){
              $(“.ui-multiselect-filter input”).trigger(‘click’);                    
          }
    }).multiselectfilter();

    Thanks,
    Ashish Kataria

  • Anonymous

    I just installed this into a zend framework site. The button wasn’t showing the quantity of options selected so while watching the code in firebug i noticed it is not setting aria-selected=”true” as it does on a working static html page. I am running the latest jquery and my ui is 1.8.11. It works on the static page but not in zend.

  • Anonymous

    I just wanted to update my comment and say the css/jquery was conflicting with jQuery validation plug-in pre-1.5.2 which was on a line after the multi select js file, i’ve moved this file further up in the header and it is now working.

  • Mauricio Garcia

    $(“#ProductCategory”).attr(“value”,”3″);$widget = $(“#ProductCategory”).multiselect(“refresh”);
    :)

  • Eddie Shipman

    Including in a centered div causes problems.
    makes even the options show centered.

    How do I make the control centered in the container but not it’s contents?

  • Michael Tangorre

    Hi Eric  -

    Great widget!  I have one issue though… how in the world do you “reset” a single select (multiple=false) back to a blank option once you have an option selected? Am I overlooking something here?  :-)

  • http://twitter.com/wadexyz wadexyz

    Having trouble with ‘minWidth’.   On the surface, it’s working (i.e. – the field width changes), but the text of the items is still wrapping as if it was the default width (i.e. – 225).

    Has anyone else encountered this?   Thx.

  • http://twitter.com/wadexyz wadexyz

    Sorry, this was just my css issue.   I had css properties on my fieldset-related attributes to help me with my form layout, and I was setting a width for the tag.    This was interfering with the multiselect, as it must also use to render things.   Solved by adding class names.

  • Gary Zhu

    I’ve ran into a problem with the “# selected” option, 
    my noneSelectedText is “Order #”,
    my selectedText is “Order # [#]”

    is there a way to escape the first #.     so I can get  ”Order # [5]“, instead of  ”Order 5 [5]”
    thanks.

  • Gary Zhu

    I tried to change selectedText  to  ”Order &#35; [#]” , but that didn’t work because the # in the code is getting replace too.

  • Shrikant

    Hi Eric,

    I am also looking for same thing. I want to make the checkboxes checked depending on comma separated value stored in another field ( say the comma separated values coming from database)

  • Anonymous

    hello eric
    using this plugin is it possible to group the selected checkboxes and display as a group,

    after selecting group of options from dropdown and click out side after clicking back on button is it possible to display all cheked options as a group

  • Sahar

    Hi. Requiring your URGENT reply.
    I aint a jQuery guy, so here my problem is: Respecting mutliselect menu, how am I able to get output(s) of the selected option(s) and send it to php for further use of it?
    I’m not a pro so please kindly and if possible step by step explain what I should exactly do with this:
    var array_of_checked_values = $(“select”).multiselect(“getChecked”).map(function(){
    return this.value;
    }).get();

  • http://www.euandroid.com.br Tsuharesu Luciel

    Here too Regis? XD

  • Nils Krueger

    Hi.
    I’m wondering why you need the name=”multiselect_’+id+’” on the checkboxes inside the menu? This leads to the situation that selected values are submiited twice. Once for the original select and once for the “multiselect_…” values. Is this the intended behaviour? Or is it just a strange behaviour on my site?

  • James Hampson

    Hi, in jquery.multiselect.filter.js, line 61
    should
    instance._toggleChecked = function(flag, group){
    be
    instance._toggleState = function(flag, group){
    ?

  • Anonymous

    This was necessary when the menu was placed inside the form, but now in version 1.12 it’s appended to the body.

  • Anonymous

    No, these are separate methods. Are you seeing something weird?

  • Anonymous

    You can simply get the val() of the original select box. $(“select”).val();

  • Anonymous

    Give the select the multiple attribute, but specify multiple:false when creating the widget.

  • Anonymous

    You can append an item to the original select box, and call multiselect(“refresh”) to update the widget.

  • Rljain

    hello i m facing a problem with selected value property 
    actually what i m doing is that getting selected value on click event 
    by $(‘#dropdownname’).val() on same dropdown click event
    problem is that it will not run first time, it gives null first time and after that if i select another value it will give me first value selected
    please help me out 

  • Anonymous

    I’m having issues working with your plugin in a Struts2 application that is already using the struts-jquery plugin.  In simple standalone html files, everything looks good, but as soon as it’s implemented in my existing pages, it seems like the rendering of the multiselect is not working (I only see a simple select box like is I did a simple HTML one).

    I’ve tried playing with imports of js, css, etc. but with no results. I really like your plugin and wish I could find the solution to make it work. 

    Any idea what might be the problem ?  I’m kind of new to jquery and widgets,etc. and I’m pretty sure you may have a few hints to help me find the issue!

    Thanks!

  • kschmidt

    Hi Eric,

    Awesome widget.  Love it.  I have encountered a small problem though.  I have optgroups in the select and have set multiple=false in the multiselect.  If I click on an optgroup, the last item in the optgroup is selected visually (I’m using selectedList) and if you do a val() on the multiselect the array contains an empty item as well as every item in the optgroup.

    I would assume that clicking on the optgroup when multiple=false wouldn’t do anything at all.

    I got around this problem by using the undocumented event “beforeoptgrouptoggle” and just returning false from it.

    Thanks.

  • Faisal Shaikh

    Hi ehynds, 
    i integrated the multiselect filter plugin in my application and its working great.Howeveri am stuck at one point. i need the filter to search over optgroup label instead of options. if the searched text matches the optgroup label, it should display all the options under that optgroup along with the optgroup label. one more thing i need to do is, when i click the optgrouplabel then it should slide up/down the corresponding list of options.your help would be highly appreciated. Thanks,Faisal

  • Rljain

    can any one tell me how to select a option with value which is coming from database
    actually i m using multiselect in my project and i successfully used this on the time of inserting now on edit time i want to select value which is coming from database in a particular multiselect box 
    how to get it because $(‘#dropdown1′).val(myvalue); is not working 
    it’s urgent guys please help me out

  • Andrew White

    As above, absolutely lovely component. Not quite sure how you can “append to the original select box” With a normal select you could have an array and go
    var obj = $(“#MyDropDown”);obj.clear();for (i in propertyArray) {   obj.options[obj.options.length] = new Option(propertyValue[i], propertyArray[i]);} 
    Any tips on how to achieve this with yours?

  • Andrew White

    I have 1 multiselect box that I want to switch at run time between multiselect & non-multiselect. The code is like this:
    function setValueSetPossibilities(comparison) {    var isMultiple = (comparison.indexOf(“IN”) > -1);    if(isMultiple) {        $(“#PropertyValue”).multiselect({ multiple: true, selectedList: 4 });    } else {        $(“#PropertyValue”).multiselect({ multiple: false, selectedList: 1 });                    }    $(“#PropertyValue”).multiselect(‘refresh’);}
    Comparison being a string containing either “IN” or “=”
    The functionality works, but the checkboxes are not visible when it is set to multiple: true?

  • http://twitter.com/digiparden digiparden GmbH

    Hi, cool plugin :) I’m just curious if there is also an option to integrate images? Thx

  • Andrew White

    Is it possible to set the current value of the drop down by using the text?
    e.g. Option AOption B
    I’d like to set the displayed value of the drop down to be “Option A”

  • Clayton Dukes

    Is it just me or does check/uncheck fail when using multiselectfilter?

  • Drasko Gajic

    remove function instance._toggleChecked from jquery.multiselect.filter.js
    it will resolve the problem

  • Anonymous

    Hi erickynds ,

    You plugin is looks good. I have used it in my website camp-cor.com. but i have one issue with it. I am not able to select checkboxes in multiselect from database. I am getting selected values text from database using jquery ajax. eg. C++,Java, C#, PHP . These values are stored in my database for a particular student. But when student login in his/her profile. i am not able to again select these values in multi select automatically . Kindly help me . 

  • http://www.camp-cor.com devendra kumar kushwaha

    Please reply me , thanks in advance.

  • Chaya Cooper

    Great widget, and I found it easier to customize than most.

    The one problem I’m having is integrating it into a page where most of my dropdowns aren’t multiple selects.

    Since the design is somewhat different than the standard html dropdowns or jquery plugins, I would need to switch all my dropdowns to this, however if I assign multiple: false as the default to all the dropdowns – either as part of ech.multiselect or by typing
    $(“select”).multiselect({multiple: False}); , I can’t seem to override it for the dropdown which requires the multi-select function.

    What would be the easiest way to do this?

  • Chaya Cooper

    Great widget, and I found it easier to customize than most.

    The one problem I’m having is integrating it into a page where most of my dropdowns aren’t multiple selects.

    Since the design is somewhat different than the standard html dropdowns or jquery plugins, I would need to switch all my dropdowns to this, however if I assign multiple: false as the default to all the dropdowns – either as part of ech.multiselect or by typing
    $(“select”).multiselect({multiple: False}); , I can’t seem to override it for the dropdown which requires the multi-select function.

    What would be the easiest way to do this?

  • Chaya Cooper

    Great widget, and I found it easier to customize than most.

    The one problem I’m having is integrating it into a page where most of my dropdowns aren’t multiple selects.

    Since the design is somewhat different than the standard html dropdowns or jquery plugins, I would need to switch all my dropdowns to this, however if I assign multiple: false as the default to all the dropdowns – either as part of ech.multiselect or by typing
    $(“select”).multiselect({multiple: False}); , I can’t seem to override it for the dropdown which requires the multi-select function.

    What would be the easiest way to do this?

  • Chaya Cooper

    Great widget, and I found it easier to customize than most.

    The one problem I’m having is integrating it into a page where most of my dropdowns aren’t multiple selects.

    Since the design is somewhat different than the standard html dropdowns or jquery plugins, I would need to switch all my dropdowns to this, however if I assign multiple: false as the default to all the dropdowns – either as part of ech.multiselect or by typing
    $(“select”).multiselect({multiple: False}); , I can’t seem to override it for the dropdown which requires the multi-select function.

    What would be the easiest way to do this?

  • mark hardy

    Fantastic tool….  trying to do something a bit different with it and struggling.  I’m generating my menu dynamically from a mySQL recordset.  that works cool, so the menu is populated from whatever SQL returns.  but.  I want to have some of the check boxes already ticked when the menu pops up.  so, for exampl, SQL might give me a list of emaila ddress, and I get a check box for each one as you’d expect, I also have floating around a string containing a comma separated list of email addresses ie, ‘tom@here.com, dick@nowhere:disqus there.com etc etc’
     I’d like that the check boxes for the people in the string are already checked when the menu pops up 

  • mark hardy

    I’ve just exactly that quite easily.  the list of options comes from one SQL query, the pre-selected options comes from another.  the pre-selected SQL results I dropped in to a var  as a comma separated string called $comma_separated. the list of options is a SQL recordset called rsApprovers and I’m using the email column the menu code looks like:

    <option value="” 0) {echo “selected=”selected”";} ?>>
    0) {
    mysql_data_seek($rsApprovers, 0);
    $row_rsApprovers = mysql_fetch_assoc($rsApprovers);
    }
    ?>

     hope you can make sense/use of that

  • Carlos oliveira

    HI, great work. 
    I have a problem using the MultiSelect widget with multiple = false.I define the text of ‘noneSelectedText’ but does not appear in the selectitems.I appreciate all the help 

    thanks

  • Monirak Ngy

    Greetings.  Great work on this control btw.  Here is the scenario of the issue I am encountering:  I enter text in the filter input field.  I see a match.  But when I try to use the down-arrow (to scroll through the dropdown list) on the keyboard immediately after typing,  it doesn’t scroll though the list.  It seems as if the focus is lost for the list when entering text in the filter box.

    This is prob not an issue, but would be great to find out a way to enter text, then use the arrows to scroll through the list, without using the mouse.  Would you w=ahppen to know if there is a way to implement this?

    All The Best!

  • Anonymous

    HI This is very good plug in .. Can you please tell me how can i remove a selected element from this widget. 

    $(“#removeBtn”).click(function(){
                        var el = $(“select”).multiselect(“getChecked”);
                        alert(el);
                        el.removeAttr(‘selected’);
                        el.multiselect(‘refresh’);
                        alert(“Completed”);
                    });
    I am using this code removeBtn is my button . i need to make a code when removebutton is clicked the selected option will be removed.. but this is not working..

    Please provide me solution.
    Thanks in Adv.
    Dhrumil Shah

  • Alexk45

    Is there a way to permanently keep the multiselect displayed and open? When autoOpen is used, it still collapses if anywhere outside the multiselect is clicked.
    I tried using the close event to force it to open again, but that caused problems with other links on the page.

    Here is the code I used:

    $( “…” ).bind(“multiselectclose”, function(event, ui){
        $( “…” ).multiselect( “open” );
    });

  • Alexk45

    Unless the widget author has a specific way, I suggest you remove it from the html multiselect element first, then call the widget’s refresh method.

    Using your example, it would be:

    $(“#removeBtn”).click(function(){
          $( “select option:selected” ).remove();                  
          el.multiselect(‘refresh’);
          alert(“Completed”);
    });

  • Anonymous

    Hi Eric,

    allthough i’m a total novice to jQuery i like your widget very much.
    Could you please, give me a clue how to get the text of all selected options at the close-event?
    My intention is to show a summary of selected options from a set of 5 multiselect-boxes.

    I tried douzend of approaches in the way i use with php or C++ but jQuery is very hard for me.

    Thanks and regards
    Feinstbein