<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eric Hynds &#187; multiselect</title>
	<atom:link href="http://www.erichynds.com/tag/multiselect/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.erichynds.com</link>
	<description>Web Developer&#039;s Ramblings on JavaScript, jQuery, ColdFusion, MySQL, and other technologies.</description>
	<lastBuildDate>Mon, 02 Jan 2012 22:55:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>jQuery UI MultiSelect Widget</title>
		<link>http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/</link>
		<comments>http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 22:53:03 +0000</pubDate>
		<dc:creator>Eric Hynds</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[multiselect]]></category>

		<guid isPermaLink="false">http://www.erichynds.com/?p=832</guid>
		<description><![CDATA[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 [...]


Related posts:<ol><li><a href='http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/' rel='bookmark' title='jQuery MultiSelect Plugin w/ ThemeRoller Support'>jQuery MultiSelect Plugin w/ ThemeRoller Support</a></li>
<li><a href='http://www.erichynds.com/jquery/using-jquery-ui-widget-factory-bridge/' rel='bookmark' title='Using &lt;code&gt;$.widget.bridge&lt;/code&gt; Outside of the Widget Factory'>Using <code>$.widget.bridge</code> Outside of the Widget Factory</a></li>
<li><a href='http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/' rel='bookmark' title='A jQuery UI Growl/Ubuntu-like Notification Widget'>A jQuery UI Growl/Ubuntu-like Notification Widget</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.erichynds.com%2Fjquery%2Fjquery-ui-multiselect-widget%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.erichynds.com%2Fjquery%2Fjquery-ui-multiselect-widget%2F&amp;source=erichynds&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This is the successor and port of my original <a href="/jquery/jquery-multiselect-plugin-with-themeroller-support/">jQuery MultiSelect Plugin</a> 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.</p>
<p>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 <em>after</em> 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!)</p>
<ul>
<li>Current version: 1.12 (11/26/2011 &#8211; <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/raw/master/CHANGELOG" class="blank">changelog</a>)</li>
<li>View <a href="/examples/jquery-ui-multiselect-widget/demos/">demos</a>.</li>
<li>Download <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/raw/1.12/src/jquery.multiselect.js">source</a> or <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/raw/1.12/src/jquery.multiselect.min.js">minified</a>, and the <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/raw/1.12/jquery.multiselect.css">CSS file</a>.</li>
<li><a href="http://github.com/ehynds/jquery-ui-multiselect-widget">Follow this project on GitHub</a>.</li>
<li>Run the <a href="/examples/jquery-ui-multiselect-widget/tests/unit/">unit tests</a>.</li>
<li>Please report any bugs on the <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/issues">issue tracker</a>.
</li>
</ul>
<h2>Demo</h2>
<p>See what you&#8217;re missing out on?  Many more demos are available <a href="/examples/jquery-ui-multiselect-widget/demos/">here</a>.</p>
<select id="multiselect-demo" 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>
<option value="6">Option 6</option>
<option value="7">Option 7</option>
<option value="8">Option 8</option>
<option value="9">Option 9</option>
<option value="10">Option 10</option>
</select>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect-demo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
   selectedText<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;# of # selected&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Advanced usage using optgroups and the filtering extension:</p>
<select id="multiselect-advanced" multiple="multiple" style="width:375px">
<optgroup label="Car Manufacturers"></p>
<option value="toyota">Toyota</option>
<option value="chevrolet">Chevrolet</option>
<option value="lexus">Lexus</option>
<option value="saturn">Saturn</option>
<option value="ford">Ford</option>
<option value="mazda">Mazda</option>
<option value="honda">Honda</option>
<option value="Nissan">Nissan</option>
<option value="pontiac">Pontiac</option>
<option value="GMC">GMC</option>
<p></optgroup><br />
<optgroup label="Boat Manufacturers"></p>
<option value="whaler">Boston Whaler</option>
<option value="grady">Grady White</option>
<option value="lund">Lund</option>
<option value="bayliner">Bayliuner</option>
<option value="panga">Panga</option>
<p></optgroup><br />
</select>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect-demo&quot;</span><span style="color: #009900;">&#41;</span>
   .<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      noneSelectedText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Select car/boat manufacturers'</span>
      selectedList<span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
   .<span style="color: #660066;">multiselectfilter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="/examples/jquery-ui-multiselect-widget/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="/examples/jquery-ui-multiselect-widget/jquery.multiselect.filter.css" /><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script><script type="text/javascript" src="/examples/jquery-ui-multiselect-widget/src/jquery.multiselect.js"></script><script type="text/javascript" src="/examples/jquery-ui-multiselect-widget/src/jquery.multiselect.filter.js"></script><script type="text/javascript">$("#multiselect-demo").multiselect({ selectedText:"# of # selected" });$("#multiselect-advanced").multiselect({ selectedList:4,noneSelectedText: 'Select car/boat manufacturers' }).multiselectfilter();</script></p>
<style>.ui-multiselect-checkboxes { text-align: left !important; }</style>
<p><span id="more-832"></span></p>
<h2>Usage</h2>
<p>Using this widget is simple.  First, include the following files:</p>
<ul>
<li>jQuery 1.4.2+</li>
<li>jQuery UI 1.8 widget factory and effects (if you&#8217;d like to use them)</li>
<li>A jQuery UI theme</li>
<li>This widget: jquery.multiselect.js</li>
<li>The CSS file: jquery.multiselect.css</li>
</ul>
<p>Next construct a standard multiple select box. Do not forget the <code>multiple</code> attribute:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example&quot;</span> <span style="color: #000066;">multiple</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multiple&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>Option 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;</span>Option 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span>&gt;</span>Option 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span>&gt;</span>Option 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span>&gt;</span>Option 5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span></pre></div></div>

<p>Finally, initialize the widget on the select box once the document is ready:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#example&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See the <a href="/examples/jquery-ui-multiselect-widget/demos/">demos</a> for advanced usages and for more documentation!</p>
<h2>Options</h2>
<p>To further customize multiselect, pass in a object with one or more of the options below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// example:</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
   header<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Choose an Option!&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<table class="parameters" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th style="width:130px">Option</th>
<th>Description</th>
<th style="width:100px">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="parameter">header</td>
<td>Either a boolean value denoting whether or not to display the header, or a string value.  If you pass a string, the default &#8220;check all&#8221;, &#8220;uncheck all&#8221;, and &#8220;close&#8221; links will be replaced with the specified text.</td>
<td>true</td>
</tr>
<tr>
<td class="parameter">height</td>
<td>Height of the checkbox container (scroll area) in pixels.  If set to &#8220;auto&#8221;, the height will calculate based on the number of checkboxes in the menu.</td>
<td>175</td>
</tr>
<tr>
<td class="parameter">minWidth</td>
<td>Minimum width of the entire widget in pixels.  Setting to &#8220;auto&#8221; will disable.</td>
<td>225</td>
</tr>
<tr>
<td class="parameter">checkAllText</td>
<td>The text of the &#8220;check all&#8221; link.</td>
<td>Check all</td>
</tr>
<tr>
<td class="parameter">uncheckAllText</td>
<td>The text of the &#8220;uncheck all&#8221; link.</td>
<td>Uncheck All</td>
</tr>
<tr>
<td class="parameter">noneSelectedText</td>
<td>The default text the select box when no options have been selected.</td>
<td>Select options</td>
</tr>
<tr>
<td class="parameter">selectedText</td>
<td>
			The text to display in the select box when options are selected (if <code>selectedList</code> 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: &quot;# of # checked&quot;.</p>
<p>			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.
		</td>
<td># selected</td>
</tr>
<tr>
<td class="parameter">selectedList</td>
<td>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.</td>
<td>false</td>
</tr>
<tr>
<td class="parameter">show</td>
<td>The name of the effect to use when the menu opens.  To control the speed as well, pass in an array: <code>['slide', 500]</code></td>
<td>empty string</td>
</tr>
<tr>
<td class="parameter">hide</td>
<td>The name of the effect to use when the menu closes.  To control the speed as well, pass in an array: <code>['explode', 500]</code></td>
<td>empty string</td>
</tr>
<tr>
<td class="parameter">autoOpen</td>
<td>A boolean value denoting whether or not to automatically open the menu when the widget is initialized.</td>
<td>false</td>
</tr>
<tr>
<td class="parameter">multiple</td>
<td>If set to false, the widget will use radio buttons instead of checkboxes, forcing users to select only one option.</td>
<td>true</td>
</tr>
<tr>
<td class="parameter">classes</td>
<td>
<div class="update"><strong>New in 1.5!</strong></div>
<p>Additional class(es) to apply to BOTH the button and menu for further customization. Separate multiple classes<br />
			with a space.  You&#8217;ll need to scope your CSS to differentiate between the button/menu:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* button */</span>
<span style="color: #6666ff;">.ui-multiselect</span><span style="color: #6666ff;">.myClass</span> <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* menu */</span>
<span style="color: #6666ff;">.ui-multiselect-menu</span><span style="color: #6666ff;">.myClass</span> <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</td>
<td>empty string</td>
</tr>
<tr>
<td class="parameter">position</td>
<td>
<div class="update"><strong>New in 1.5! Requires jQuery 1.4.3+, jQuery UI position utility</strong></div>
<p>This option allows you to position the menu anywhere you&#8217;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.</p>
<p>Requires the jQuery UI <a href="http://jqueryui.com/demos/position/">position utility</a> and jQuery 1.4.3+.  Please see <a href="/examples/jquery-ui-multiselect-widget/demos/#position">this demo</a> for usage instructions.</p>
</td>
<td>empty object</td>
</tr>
</tbody>
</table>
<h2>Events</h2>
<p>Hook into any of the events below by either binding to the event name, or passing in the name of the event during initialization:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// bind to event</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;multiselectopen&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// event handler here</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// or pass in the handler during initialization</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">open</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// event handler here</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<table class="parameters" cellspacing="0" cellpadding="0" style="width:600px">
<thead>
<tr>
<th style="width:130px">Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="parameter">create</td>
<td>
<div class="update"><strong>Requires jQuery UI Widget Factory 1.8.6+</strong></div>
<p>Fires when the widget is created for the first time.
</td>
</tr>
<tr>
<td class="parameter">beforeopen</td>
<td>Fires right before the menu opens.  Prevent the menu from opening by returning false in the handler.</td>
</tr>
<tr>
<td class="parameter">open</td>
<td>Fires after the widget opens.</td>
</tr>
<tr>
<td class="parameter">beforeclose</td>
<td>Fires right before the menu closes.  Prevent the menu from closing by returning false in the handler.</td>
</tr>
<tr>
<td class="parameter">close</td>
<td>Fires after the widget closes.</td>
</tr>
<tr>
<td class="parameter">checkAll</td>
<td>Fires when all the options are checked by either clicking the &#8220;check all&#8221; link in the header, or when the &#8220;checkall&#8221; method is programatically called (see next section).</td>
</tr>
<tr>
<td class="parameter">uncheckAll</td>
<td>Fires when all the options are all unchecked by either clicking the &#8220;uncheck all&#8221; link in the header, or when the &#8220;uncheckall&#8221; method is programatically called (see next section).</td>
</tr>
<tr>
<td class="parameter">optgrouptoggle</td>
<td>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:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;multiselectoptgrouptoggle&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">/*
	event: the original event object, most likely &quot;click&quot;
&nbsp;
	ui.inputs: an array of the checkboxes (DOM elements)
        inside the optgroup
&nbsp;
        ui.label: the text of the optgroup
&nbsp;
        ui.checked: whether or not the checkboxes were
        checked or unchecked in the toggle (boolean)
	*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</td>
</tr>
<tr>
<td class="parameter">click</td>
<td>Fires when a checkbox is checked or unchecked.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;multiselectclick&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">/*
	event: the original event object
&nbsp;
	ui.value: value of the checkbox
	ui.text: text of the checkbox
	ui.checked: whether or not the input was checked
        or unchecked (boolean)
	*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</td>
</tr>
</tbody>
</table>
<h2>Methods</h2>
<p>After an instance has been initialized, interact with it by calling any of these methods:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// example:</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#multiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;method_name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<table class="parameters" cellspacing="0" cellpadding="0" style="width:600px">
<thead>
<tr>
<th style="width:130px">Method</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="parameter">open</td>
<td>Opens the menu.</td>
</tr>
<tr>
<td class="parameter">close</td>
<td>Closes the menu.</td>
</tr>
<tr>
<td class="parameter">refresh</td>
<td>
<div class="update"><strong>New in 1.8!</strong></div>
<p>Reloads the checkbox menu.  If you&#8217;re dynamically adding/removing option tags on the original select via AJAX or DOM manipulation methods, call <code>refresh</code> to reflect the changes in the widget.</td>
</tr>
<tr>
<td class="parameter">disable</td>
<td>Disable the entire widget.</td>
</tr>
<tr>
<td class="parameter">enable</td>
<td>Enable the entire widget.</td>
</tr>
<tr>
<td class="parameter">checkAll</td>
<td>Check all checkboxes.</td>
</tr>
<tr>
<td class="parameter">uncheckAll</td>
<td>Uncheck all checkboxes.</td>
</tr>
<tr>
<td class="parameter">isOpen</td>
<td>Returns a boolean denoting if the widget is currently open or not.</td>
</tr>
<tr>
<td class="parameter">getChecked</td>
<td>Returns an array of all the checked checkboxes.</td>
</tr>
<tr>
<td class="parameter">widget</td>
<td>Returns the menu container (all checkboxes inside).</td>
</tr>
<tr>
<td class="parameter">option</td>
<td>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.</td>
</tr>
<tr>
<td class="parameter">destroy</td>
<td>Destroy the widget, and revert back to the original select box.</td>
</tr>
</tbody>
</table>
<h2>Filter Plugin</h2>
<p>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 <a href="/examples/jquery-ui-multiselect-widget/demos/index.htm#filter">demo page</a>.</p>
<h2>How do I&#8230;?</h2>
<p>These questions came out of the comments which others will probably find useful:</p>
<h3>Set default options for all multiselect instances?</h3>
<div style="margin-left:20px">
<p>The options object is located in <code>$.ech.multiselect.prototype.options</code>.  To configure options	that all new instances will inherit, it&#8217;s easier to set them in this object instead of on an instance-by-instance basis.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">ech</span>.<span style="color: #660066;">multiselect</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">options</span>.<span style="color: #660066;">selectedText</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;# of # selected&quot;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<h3>Retrieve all selected values?</h3>
<div style="margin-left:20px">
<p>The easiest way is to call <code>val()</code> on the select box:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> values <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The same can be accomplished using the multiselect API. Call the <code>getChecked</code> method and map a new array:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> array_of_checked_values <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;getChecked&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<h3>Retrieve values on the server?</h3>
<div style="margin-left:20px">
<p>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&#8217;ll degrade a bit better.</p>
</div>
<h3>Prevent the <code>selectedList</code> option from increasing the button&#8217;s height?</h3>
<div style="margin-left:20px">
<p>Open up the CSS file and edit the .ui-multiselect declaration.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui-multiselect</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span> overflow-x<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The height you&#8217;ll need to set depends on the font size and padding you use, so it may need adjusting.</p>
</div>
<h3>Manually check or uncheck a checkbox?</h3>
<div style="margin-left:20px">
<p>The checkboxes can be accessed after calling the &quot;widget&quot; method.  Simply manually trigger the NATIVE click event on them:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// manually check (or uncheck) the third checkbox in the menu:</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiselect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;widget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:checkbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The native click event must be used (<code>trigger('click')</code> will not work) due to <a href="http://bugs.jquery.com/ticket/3827">this bug</a> in jQuery&#8217;s core.</p>
<p>All necessary events and actions, like updating the button value, will automatically fire.</p>
<p>Alternatively, you could give the original <code>option</code> tag the <code>selected</code> attribute, and then call MultiSelect&#8217;s <code>refresh</code> method.</p>
</div>
<h3>Show checked values on another part of my page?</h3>
<div style="margin-left:20px">
<p>See this demo: <a href="http://jsfiddle.net/ehynds/rTjkr/">http://jsfiddle.net/ehynds/rTjkr/</a></p>
</div>
<h3>Use multiselect in conjunction with the validate plugin?</h3>
<div style="margin-left:20px">
Make sure you&#8217;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 &#8220;delegate&#8221; method which conflicts with the method added in jQuery.  The conflict was resolved in Validate 1.7.
</div>
<h2>Issues</h2>
<p>If you find any issues, please report them using the <a href="http://github.com/ehynds/jquery-ui-multiselect-widget/issues" class="blank">GitHub issue tracker</a>.  Thanks!</p>


<p>Related posts:<ol><li><a href='http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/' rel='bookmark' title='jQuery MultiSelect Plugin w/ ThemeRoller Support'>jQuery MultiSelect Plugin w/ ThemeRoller Support</a></li>
<li><a href='http://www.erichynds.com/jquery/using-jquery-ui-widget-factory-bridge/' rel='bookmark' title='Using &lt;code&gt;$.widget.bridge&lt;/code&gt; Outside of the Widget Factory'>Using <code>$.widget.bridge</code> Outside of the Widget Factory</a></li>
<li><a href='http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/' rel='bookmark' title='A jQuery UI Growl/Ubuntu-like Notification Widget'>A jQuery UI Growl/Ubuntu-like Notification Widget</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/feed/</wfw:commentRss>
		<slash:comments>498</slash:comments>
		</item>
		<item>
		<title>jQuery MultiSelect Plugin w/ ThemeRoller Support</title>
		<link>http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/</link>
		<comments>http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 14:47:03 +0000</pubDate>
		<dc:creator>Eric Hynds</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[multiselect]]></category>
		<category><![CDATA[themeroller]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.erichynds.com/?p=240</guid>
		<description><![CDATA[07-09-2010 &#8211; This plugin has been re-written! I&#8217;ve re-written this plugin using the jQuery UI widget factory. As such, a number of new features have been added, bugs fixed, and performance issues addressed. Use the widget version instead &#8211; I won&#8217;t be doing any further development on this version. I&#8217;ve been working on a multiple [...]


Related posts:<ol><li><a href='http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/' rel='bookmark' title='jQuery UI MultiSelect Widget'>jQuery UI MultiSelect Widget</a></li>
<li><a href='http://www.erichynds.com/jquery/jquery-related-dependent-selects-plugin/' rel='bookmark' title='jQuery Related (Dependent) Selects Plugin'>jQuery Related (Dependent) Selects Plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.erichynds.com%2Fjquery%2Fjquery-multiselect-plugin-with-themeroller-support%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.erichynds.com%2Fjquery%2Fjquery-multiselect-plugin-with-themeroller-support%2F&amp;source=erichynds&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="update" style="margin-top:15px;padding:10px;width:525px">
<div class="bold" style="font-size:16px">07-09-2010 &#8211; This plugin has been re-written!</div>
<p>I&#8217;ve <a href="/jquery/jquery-ui-multiselect" class="bold">re-written</a> this plugin using the jQuery UI widget factory.  As such, a number of new features have been added, bugs fixed, and performance issues addressed.  </p>
<p><a class="bold" href="/jquery/jquery-ui-multiselect">Use the widget version instead</a> &#8211; I won&#8217;t be doing any further development on this version.
</div>
<p>I&#8217;ve been working on a multiple select plugin on and off for the past couple months and finally have it stable enough for a first release.  When I started this project my intentions were only to re-factor <a href="http://abeautifulsite.net/2008/04/jquery-multiselect/">Cory LaViska&#8217;s MultiSelect</a> implementation, but it quickly turned into a complete re-write with a focus on speed and ThemeRoller support.  This plugin turns an ordinary HTML select control into an elegant drop down list of checkboxes.<br />
<img style="float: right; padding: 5px 0 10px 10px;" src="/examples/jquery-multiselect/screenshot.gif" alt="jQuery MultiSelect" /></p>
<ul>
<li>Current version: 0.6 (05/04/2010 &#8211; <a href="http://github.com/ehynds/jquery-multiselect/raw/0.6/CHANGELOG" class="blank">Changelog</a>)</li>
<li><a class="blank" href="/examples/jquery-multiselect/examples.htm">View demos</a></li>
<li>Download <a class="blank" href="http://github.com/ehynds/jquery-multiselect/raw/0.6/src/jquery.multiselect.js">source (12.5 kb)</a> or <a class="blank" href="http://github.com/ehynds/jquery-multiselect/raw/0.6/src/jquery.multiselect.min.js">minified (6.8 kb)</a>, and the <a href="http://github.com/ehynds/jquery-multiselect/raw/0.6/jquery.multiselect.css" class="blank">CSS file</a>.</li>
<li>Follow this project on <a class="blank" href="http://github.com/ehynds/jquery-multiselect">GitHub</a></li>
</ul>
<h2>Features</h2>
<ul>
<li>Full ThemeRoller support.</li>
<li>Optgroup support with clickable labels.</li>
<li>Optional header with check all / uncheck all / close links.</li>
<li>Degrades gracefully.</li>
<li>Keyboard support.</li>
<li>Ability to hook into 5 different event callbacks.</li>
<li>Display the checked options in a list with a configurable maximum.</li>
<li>Easily change the position, fade speed, scroll container height, links text, and input text.</li>
<li>The widget width inherits from the original element, but is also configurable as a parameter.</li>
<li>Pre-selected &#038; disabled option/widget support.</li>
<li>bgiframe support.</li>
<li>Only 6.9kb minified (2kb Gzipped).</li>
</ul>
<p><span id="more-240"></span></p>
<h2>Compatibility</h2>
<p>MultiSelect is compatible with jQuery 1.4.0+ and all themes from jQuery UI 1.7+.  This plugin is known to work in (but not limited to):</p>
<ul>
<li>Firefox 2 &#8211; 3.6</li>
<li>IE 6 &#8211; 8</li>
<li>Chrome Beta/4</li>
<li>Safari 4</li>
<li>Opera 10</li>
</ul>
<h2>Usage</h2>
<p>First ensure you&#8217;ve included jQuery 1.4, a jQuery UI theme of your choice, and the jquery.multiselect.css file.  You don&#8217;t need the jQuery UI library itself, just the theme files.  The simplest use of MultiSelect is to bind the widget to your select box:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MySelectBox&quot;</span> <span style="color: #000066;">multiple</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multiple&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MySelectBox&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>Option 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;</span>Option 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#MySelectBox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Do not forget to set your select boxes to <code>multiple="multiple"</code> if you want this plugin to degrade gracefully.  Any option tags with the <code>selected="selected"</code> attribute will automatically be checked by default, and any option tags with the <code>disabled="disabled"</code> attribute will automatically be disabled by default.</p>
<h3>Callbacks</h3>
<p>Inside the <code>onOpen</code> callback, <code>this</code> refers to the container holding the header and checkboxes.  If you want to gather all the checkboxes inside the multiselect that just opened, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#MySelectBox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	onOpen<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> $checkboxes <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inside the <code>onClick</code> callback, <code>this</code> refers to the checkbox that received the event.  Example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#MySelectBox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	onClick<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;I was just checked!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See the options below for a full list of callbacks.</p>
<h3>Overriding Options</h3>
<p>Options for this plugin are exposed in <code>$.fn.multiSelect.defaults</code>, so you can override the default options for all instances like such:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// set the minWidth parameter for all instances to 500 pixels</span>
$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">multiSelect</span>.<span style="color: #660066;">defaults</span>.<span style="color: #660066;">minWidth</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Passing a function to the selectedText parameter</h3>
<p>As of 0.5, the selectedText parameter can accept 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.  As you can see in the example, this gives you 100% control of the display:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#MySelectBox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">multiSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	selectedText<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>numChecked<span style="color: #339933;">,</span> numTotal<span style="color: #339933;">,</span> checkedInputs<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// example: emulating the default behavior</span>
		<span style="color: #000066; font-weight: bold;">return</span> numChecked <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; checked&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
		<span style="color: #006600; font-style: italic;">// example: emulating the selectedList option</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>numChecked <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span> 
			<span style="color: #339933;">?</span> checkedInputs.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> element.<span style="color: #660066;">title</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">', '</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">:</span> numChecked <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; checked&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Options</h2>
<p>This plugin is configurable with the following options:</p>
<table class="parameters" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th style="width:125px">Parameter</th>
<th>Description</th>
<th style="width:115px">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="parameter">showHeader</td>
<td class="">A boolean value denoting whether or not to display the header containing the check all, uncheck all, and close links.</td>
<td>true</td>
</tr>
<tr>
<td class="parameter">maxHeight</td>
<td class="">The maximum height in pixels of the scrolling container that holds the checkboxes.</td>
<td>175</td>
</tr>
<tr>
<td class="parameter">minWidth</td>
<td class="">The minimum width in pixels of widget.  Setting to <code>auto</code> (default) will inherit the width from the original select element.</td>
<td>200</td>
</tr>
<tr>
<td class="parameter">checkAllText</td>
<td class="">The default text of the &#8220;Check all&#8221; link.</td>
<td>Check all</td>
</tr>
<tr>
<td class="parameter">unCheckAllText</td>
<td class="">The default text of the &#8220;Uncheck all&#8221; link.</td>
<td>Uncheck all</td>
</tr>
<tr>
<td class="parameter">noneSelectedText</td>
<td class="">
<div class="update">Renamed from <code>noneSelected</code> in 0.5!</div>
<p> The default text the select box when no options have been selected.</td>
<td>Select options</td>
</tr>
<tr>
<td class="parameter">selectedList</td>
<td class="">A boolean/numeric 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 <code>selectedText</code> parameter.  A value of 0 or <code>false</code> is disabled.</td>
<td>false</td>
</tr>
<tr>
<td class="parameter">selectedText</td>
<td class="">
<p>The text to display in the select box when options are selected (if selectedList is false).  The pound sign (#) is 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: &#8220;# of # checked&#8221;.</p>
<p>
<div class="update">New in 0.5!</div>
<p>As of 0.5, this parameter can also accept 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 the examples.</p>
</td>
<td># selected</td>
</tr>
<tr>
<td class="parameter">position</td>
<td class="">The position of the options menu relative to the input control: top, middle, or bottom.</td>
<td>bottom</td>
</tr>
<tr>
<td class="parameter">shadow</td>
<td class="">A boolean value denoting whether to apply a CSS shadow (class ui-multiselect-shadow).</td>
<td>false</td>
</tr>
<tr>
<td class="parameter">fadeSpeed</td>
<td class="">How fast (in ms) to fade out the options menu on close.</td>
<td>200</td>
</tr>
<tr>
<td class="parameter">state</td>
<td class="">
<div class="update">New in 0.5!</div>
<p> The default state of the widget.  Either open or closed.</td>
<td>closed</td>
</tr>
<tr>
<td class="parameter">disabled</td>
<td class="">
<div class="update">New in 0.5!</div>
<p> Whether or not to disabled the widget by default.  <b>Important:</b> see the &#8220;Known Issues&#8221; section below for more documentation on this.</td>
<td>false</td>
</tr>
<tr>
<td class="parameter">onCheck</td>
<td class="">A callback to fire when a checkbox is checked.</td>
<td>Function</td>
</tr>
<tr>
<td class="parameter">onOpen</td>
<td class="">A callback to fire when the options menu is opened.</td>
<td>Function</td>
</tr>
<tr>
<td class="parameter">onCheckAll</td>
<td class="">A callback to fire when the &#8220;Check all&#8221; link is clicked.</td>
<td>Function</td>
</tr>
<tr>
<td class="parameter">onUncheckAll</td>
<td class="">A callback to fire when the &#8220;Uncheck all&#8221; link is clicked.</td>
<td>Function</td>
</tr>
<tr>
<td class="parameter">onOptgroupToggle</td>
<td class="">A callback to fire when the opgroup header is clicked.  An array of checkboxes inside the optgroup is passed as an optional argument.</td>
<td>Function</td>
</tr>
</tbody>
</table>
<p></p>
<p><a name="issues"></a></p>
<h2>Known Issues</h2>
<p>A few issues are still outstanding:</p>
<ul>
<li>No onClose callback yet.</li>
<li>The position should automatically change if the current position will prevent the options menu from showing.  E.g., if the input is at the bottom of the page, the options should appear not appear below the input.</li>
<li>In IE, the shadow parameter increases the width and height of the container, rendering it a few pixels wider than the input and throwing off the alignment.  You can easily edit the CSS file and remove the IE-specific shadow filters, however, or opt not to use it.</li>
<li>If the select box you&#8217;re transforming into a multiselect is disabled, the option tags will actually inherit the disabled property only in webkit; Firefox and IE do not display this behavior.  I&#8217;ve <a href="http://dev.jquery.com/ticket/6211">filed a bug</a> on this.  Therefore, to be cross-browser compatible, if the entire widget is disabled by default, the class ui-state-disabled is applied and the disabled attribute is removed.  This is important to note because checkbox values could be transmitted during submit, even if the select is disabled.  To toggle disabled state, toggle the ui-state-disabled class on the widget.
<p>This bug does NOT effect the disabled state of specific option tags.</li>
</ul>
</pre>


<p>Related posts:<ol><li><a href='http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/' rel='bookmark' title='jQuery UI MultiSelect Widget'>jQuery UI MultiSelect Widget</a></li>
<li><a href='http://www.erichynds.com/jquery/jquery-related-dependent-selects-plugin/' rel='bookmark' title='jQuery Related (Dependent) Selects Plugin'>jQuery Related (Dependent) Selects Plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/feed/</wfw:commentRss>
		<slash:comments>259</slash:comments>
		</item>
	</channel>
</rss>

