views:

144

answers:

1

edited my original question

The problem is the same for setting the id off a newly added element or if I use the argument noteid from the function. The result is that every element get's the same id if this function get's looped.

How can I set a different id for every newly added element???

As it is now, the value in the submit event is the same for every element. If I have to loop this function to create multiple notes based on database entry's only the last added noteid is remembered and every element uses that same id.

You can see what happens if you see the page First you have to create like two notes by clicking the icon with the arrow Then delete the top one followed by a page refresh. You wil see the second one is deleted.

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

+1  A: 

You will have to remember that this function gets looped from another function! You can see that from my page

I also found this comment on the same issue I believe but I don't understand the solution

I have to test that out

I did not know how to test it

I solved the problem by removing the load method and the binding off the submit event Maybe it was getting to complicated for jquery to handle

Instead off load I use the prepend method and I use a normal click event with live

It is also a lot easyer to add variables into it. It's almost the same as echo from php

Ignore my previous suggestion, the "self=this" will not help you in this case. There are too many things going on here. The loading and replacing of the html on top of the submit, etc. This needs to be simplified or it will be very difficult to provide you with an answer.
Jose Basilio
I will remove the binding off the submit event and use a normal button. This way live supports the clickevent