Set a different id for each new item in the callback from the load event
edited my original question
The problem is the same for setting id from a newly added element or if I use the argument note from a function. As a result, each element gets the same identifier if this function turns out to be closed.
How can I set a different id for each newly added item ???
As it is now, the value in the submit event is the same for every element. If I need to loop this function to create multiple notes based only on a database record, the last added note is remembered and each item uses the same ID.
You can see what happens if you see the page First you have to create as two notes by clicking the arrow icon Then delete the top one followed by a page refresh. You will see that the second one is removed.
newnote(tbnoteid){
$('.wrappertbnote:last').load('tbnote.html .paneltbnote', function() {
var t = this;
var tt= $(t).children(1).children("form").children("#frmnoteid");
$(tt).attr('id' , tbnoteid);
$(".frmremovetbnote:last").submit(function(){
var idvalue = $(tt).attr('id');
$.post("tbnotesact.php",{
noteid: tbnoteid,
action: "remove",
time: timestamp
}, function(xml) {
thanks richard
You will need to remember that this function is looping from another function! You can see this on my page
I also found this comment on the same problem that I believe but I don't understand the solution
I need to check this
I didn't know how to test it
I solved the problem by removing the upload method and binding to the dispatch event It might have been difficult for jquery for jQuery to deal with
Instead of loading I use prepend method and I use normal click event with live
It's also much easier to add variables to it. This is almost the same as echo from php