Skip to content
Snippets Groups Projects
Commit 8e4832bd authored by Michael Gapczynski's avatar Michael Gapczynski
Browse files

Prevent adding a duplicate to a multiselect

parent 05cb9480
No related branches found
No related tags found
No related merge requests found
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment