diff options
author | lou <louiscuny@gmail.com> | 2011-05-03 23:36:09 +0200 |
---|---|---|
committer | lou <louiscuny@gmail.com> | 2011-05-03 23:36:09 +0200 |
commit | 7d3d5c39adc1f88ca79b78cf008ad2f015096849 (patch) | |
tree | 4e8c61a83af40d20c63a5594c7714728420c68f3 | |
parent | a5535db7e6ce9f71c6534420cfa799792b0ae14b (diff) | |
download | multi-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.zip multi-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.tar.gz multi-select-7d3d5c39adc1f88ca79b78cf008ad2f015096849.tar.bz2 |
generate select id if none
-rw-r--r-- | documentation.html | 2 | ||||
-rw-r--r-- | index.html | 4 | ||||
-rw-r--r-- | js/jquery.multi-select.js | 6 |
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> @@ -35,7 +35,7 @@ <h2>Making your <select> 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'> - <select multiple='multiple' class='your_class' id='your_id'> + <select multiple='multiple' class='your_class'> <option value='fr'>France</option> ... </select></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(), |