summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlou <louiscuny@gmail.com>2011-05-03 23:36:09 +0200
committerlou <louiscuny@gmail.com>2011-05-03 23:36:09 +0200
commit7d3d5c39adc1f88ca79b78cf008ad2f015096849 (patch)
tree4e8c61a83af40d20c63a5594c7714728420c68f3
parenta5535db7e6ce9f71c6534420cfa799792b0ae14b (diff)
downloadmulti-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.zip
multi-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.tar.gz
multi-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.tar.bz2
generate select id if none
-rw-r--r--documentation.html2
-rw-r--r--index.html4
-rw-r--r--js/jquery.multi-select.js6
3 files changed, 7 insertions, 5 deletions
diff --git a/documentation.html b/documentation.html
index 549834b..133940d 100644
--- a/documentation.html
+++ b/documentation.html
@@ -63,7 +63,7 @@
</table>
<h2>Methods</h2>
<p>
- You must init the multiple select by calling $('#my-select').multiSelect() before calling one of the following methods.
+ You must init the multiple select with $('#my-select').multiSelect() before calling one of the following methods.
</p>
<br/>
<table>
diff --git a/index.html b/index.html
index b0e4ea4..aeb2767 100644
--- a/index.html
+++ b/index.html
@@ -35,7 +35,7 @@
<h2>Making your &lt;select&gt; with multiple attribute not suck !</h2>
<div id='demo'>
<form>
- <select multiple='multiple' class='multiselect' id='simpleCountries'>
+ <select multiple='multiple' class='multiselect'>
<option value='fr'>France</option>
<option value='ca'>Canada</option>
<option value='ar'>Argentina</option>
@@ -68,7 +68,7 @@
</p>
<pre>
<code class='html'>
- &lt;select multiple='multiple' class='your_class' id='your_id'&gt;
+ &lt;select multiple='multiple' class='your_class'&gt;
&lt;option value='fr'&gt;France&lt;/option&gt;
...
&lt;/select&gt;</code>
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js
index 8090cd5..39759f9 100644
--- a/js/jquery.multi-select.js
+++ b/js/jquery.multi-select.js
@@ -12,8 +12,10 @@
multiSelects.hide();
multiSelects.each(function(){
- var ms = $(this),
- container = $('<div id="ms-'+ms.attr('id')+'" class="ms-container"></div>').detach(),
+
+ var ms = $(this);
+ var msId = ms.attr('id') != undefined ? ms.attr('id') : 'select'+((new Date()).getTime());
+ var container = $('<div id="ms-'+msId+'" class="ms-container"></div>').detach(),
selectableContainer = $('<div class="ms-selectable"></div>').detach(),
selectedContainer = $('<div class="ms-selection"></div>').detach(),
selectableUl = $('<ul></ul>').detach(),