Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you click in two 'addable's you'll get 3 commas</p> <p>the problem is that you are attaching a new keypress handler everytime a the 'li' is clicked, if that element passes this test</p> <pre><code>if($(this).hasClass("custom-add") </code></pre> <p>just attach it once</p> <pre><code>$('li').click(function() { if($(this).hasClass("addable")) { var myitemname = $(this).attr('id')+','; $("input#edit-recipients").val($("input#edit-recipients").val() + myitemname); $(this).removeClass("addable").addClass("removable").appendTo($("ul#selected")); } else if($(this).hasClass("removable")) { var myitemname = $(this).attr('id')+','; var currentValue = $("input#edit-recipients").val(); currentValue = currentValue.replace(myitemname,""); $("input#edit-recipients").val(currentValue); $(this).removeClass("removable").addClass("addable").appendTo($("ul#iin")); } else if($(this).hasClass("oon-all")) { $('li.addable').each(function() { var myitemname = $(this).attr('id')+','; $("input#edit-recipients").val($("input#edit-recipients").val() + myitemname); $(this).removeClass("addable").addClass("removable").appendTo($("ul#selected")); }); } }); $('input#add-oon').keypress(function(e) { if(e.keyCode == 13) { e.preventDefault(); var addValue = $('input#add-oon').val(); $('input#add-oon').val(""); var lid = addValue.replace(/ /g, "-"); $('input#edit-recipients').val($('input#edit-recipients').val() + addValue + ','); var clone = $('#cloneable').html(); $elem = $(clone).find('div.realname').text(addValue).parent().parent().parent(); $('ul#selected').append($elem); $('#'+lid).click(function() { var currentValue = $("input#edit-recipients").val(); currentValue = currentValue.replace(addValue+',',""); $("input#edit-recipients").val(currentValue); $(this).remove(); }); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload