<?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; UI</title>
	<atom:link href="http://www.erichynds.com/tag/ui/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 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>

