Dynamicly created elements have events firing multiple times
Hi, sorry if this has been posted before but my brain is on the verge of exploding.
I have a group of elements in a div. the group has an add and a remove button. on clicking the add it duplicates the whole div and adds it to the parent div. this works fine. I save it then I go and reload the page the data comes back from the db and populates two copies of the div now, since I hit the add button. so now I hit the add button again to add a third item. but instead of one I get two. lets say I save 5 of them I come back and hit add and I get five new ones instead of just one.
So obviously the event is getting bound to the add button of each item and they are all firing. I just don't know how to get it to only fire once. per click.
this is actually very much simplified. It's much more complex. it practice I have a group with items, I can add additional items. or I can add an additonal group. and add items to either group and so on recursively. sometimes it works and sometimes I get some crazy behavior. to make matters worse I use this little control in a number of places on the screen so it was duplicating every version not just the one that were created in a particular instance. I added some dynamic naming and now I think it's isolated to just the instance I'm displaying.
Anyway, if this makes any sense and you have any idea how to help me please let me know.
thanks,
Raif