diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-06-29 16:44:08 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-01 11:36:44 -0400 |
commit | dd7d34a40eca404240da6923115d375d041b1bd1 (patch) | |
tree | 787e678242f877aa6dd5563b3fc57f32b251c1e3 /core/js/multiselect.js | |
parent | 949cab7ea17ed7e12b27886d46f45e541b138850 (diff) | |
download | nextcloud-server-dd7d34a40eca404240da6923115d375d041b1bd1.tar.gz nextcloud-server-dd7d34a40eca404240da6923115d375d041b1bd1.zip |
Prevent adding a duplicate to a multiselect
Diffstat (limited to 'core/js/multiselect.js')
-rw-r--r-- | core/js/multiselect.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/js/multiselect.js b/core/js/multiselect.js index ba89c1bb563..c4fd74b0475 100644 --- a/core/js/multiselect.js +++ b/core/js/multiselect.js @@ -129,13 +129,24 @@ if(event.keyCode == 13) { event.preventDefault(); event.stopPropagation(); + var value = $(this).val(); + var exists = false; + $.each(options,function(index, item) { + if ($(item).val() == value) { + exists = true; + return false; + } + }); + if (exists) { + return false; + } var li=$(this).parent(); $(this).remove(); li.text('+ '+settings.createText); li.before(createItem(this)); var select=button.parent().next(); var option=$('<option selected="selected"/>'); - option.attr('value',$(this).val()); + option.attr('value',value); option.text($(this).val()); select.append(option); li.prev().children('input').trigger('click'); |