Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The line:</p> <pre><code>$(".del").click(function(){ </code></pre> <p>is returning all the elements with a class of <code>del</code> which means every time you add a new item you're adding a new event to each existing <code>del</code> element. (Glancing at the rest of your code this is going to be an issue for most of your elements apparently).</p> <p>Your best option is to assemble the elements that make up each new item individually and assign specific events to them before appending them to the content. That way you know each specific element will have a single correct even associated with it.</p> <p>EDIT:</p> <p>passing data to a new function:</p> <pre><code> $("#save").click(function(){ var ul = $("ul.addul"); var addM = $(".mo").val(); var addY = $(".yr").val(); var addC = $(".ct").val(); var addT = $("textarea#addThoughts").val(); //submit the add $.post("save.php", { month : addM, year : addY, cottage : addC, thoughts : addT }, function(data){ //all good if(data.success) { run_success(data); } }//close function }//close #save click //new, global function function run_success(data) { //do things with data here } </code></pre> <p>Setting up a global variable:</p> <pre><code> $("#save").click(function(){ var ul = $("ul.addul"); var addM = $(".mo").val(); var addY = $(".yr").val(); var addC = $(".ct").val(); var addT = $("textarea#addThoughts").val(); //submit the add $.post("save.php", { month : addM, year : addY, cottage : addC, thoughts : addT }, function(data){ //all good if(data.success) { my_global_var = data; //note, my_global_var is created without a var //before it, thereby assigning it a global scope } }//close function }//close #save click </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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