Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery - strange behavior on appending input
    text
    copied!<p>Most of the code works as expected, but I'm getting some unusual behavior under a very specific circumstance that I'm totally confused about... </p> <p>I'm moving elements from div to div depending on the class of the one that is picked. I've got all of that working...</p> <p>I'm now trying to implement an input field that will take a value, create an <code>&lt;li&gt;</code> element out of it, and append it to another div. I've got that working as well. </p> <p>The problem that I'm having is I keep getting an extra blank li added if I click out of the input field and then back in it and add something... I can see (in the jsfiddle link) that it's inserting 2 commas, and that's likely why I'm getting an additional blank li, but I can't pinpoint where that's happening... </p> <p><strong>I'm trying to achieve the following:</strong></p> <ol> <li>A user enters text into the input field and hits enter. &lt;-- works </li> <li>An <code>&lt;li&gt;</code> element is created (with a class of "oon") and appended to ul#selected. &lt;-- works </li> <li>If a user clicks on <code>&lt;li class="oon"&gt;</code>, it is removed &lt;-- works</li> </ol> <p><strong>The Problem</strong></p> <ol> <li>I click in an input field and enter some text and hit enter. If I stay in the input field and keep typing values and hitting enter, it always works as expected. </li> <li>I click on another element with the class "addable". That gets appended as expected. </li> <li>I return to the input field and enter some text and hit enter. Now, what I typed in is appended just as it is in Problem (1), but it also adds on an additional li element with an empty id and no text</li> </ol> <p>Per someone's comment, I posted the code here: <a href="http://jsfiddle.net/vvF7v/11/" rel="nofollow">http://jsfiddle.net/vvF7v/11/</a></p>
 

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