diff options
author | Louis Cuny <louiscuny@gmail.com> | 2012-04-16 22:20:34 +0200 |
---|---|---|
committer | Louis Cuny <louiscuny@gmail.com> | 2012-04-16 22:20:34 +0200 |
commit | 784655e360c52fbc527fe5f3464de3360d77a776 (patch) | |
tree | 8afe72e36746268a9c692d01dbdf0aebf879f906 | |
parent | 3a143cd138634f8df333a743122a50a04e245b02 (diff) | |
download | multi-select-784655e360c52fbc527fe5f3464de3360d77a776.zip multi-select-784655e360c52fbc527fe5f3464de3360d77a776.tar.gz multi-select-784655e360c52fbc527fe5f3464de3360d77a776.tar.bz2 |
prevent selection of already selected or undefined elements
-rw-r--r-- | css/application.css | 5 | ||||
-rw-r--r-- | demos.html | 2 | ||||
-rw-r--r-- | js/jquery.multi-select.js | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/css/application.css b/css/application.css index 5d90b24..ed7f18f 100644 --- a/css/application.css +++ b/css/application.css @@ -265,4 +265,9 @@ form{ width: 398px; float: left; margin: 20px 0px; +} + +#search{ + width: 165px; + font-size: 14px; }
\ No newline at end of file @@ -237,7 +237,7 @@ </form> </div> <div class='searchable' style='display:none'> - <input type="text" id="search" autocomplete = "off" /> + <input type="text" id="search" autocomplete = "off" placeholder="search country"/> <form id='searchable-form' action='http://localhost:4567/ms' method='post'> <select name='countries[]' multiple='multiple' id='searchable-select'> <option value='fr' selected='selected'>France</option> diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index 4d1317f..e9ead2a 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -184,11 +184,11 @@ haveToSelect = null; if (method == 'init'){ - haveToSelect = selectableLi.hasClass(ms.data('settings').disabledClass) && value != '' && selectedOption.attr('selected'); + haveToSelect = selectableLi.hasClass(ms.data('settings').disabledClass) && selectedOption.attr('selected'); } else { - haveToSelect = !(selectableLi.hasClass(ms.data('settings').disabledClass)) && value != ''; + haveToSelect = !(selectableLi.hasClass(ms.data('settings').disabledClass)); } - if (haveToSelect ){ + if (haveToSelect && value && value != '' && selectedUl.children('li[ms-value="'+value+'"]').length == 0){ ms.focus(); var parentOptgroup = selectableLi.parent('.ms-optgroup'); if (parentOptgroup.length > 0) |