When a data is added, the dynamic loading is displayed in the interface. Later, a serious bug is discovered, and the note I did as an example, when I add a data After that, then when you click Delete, you will be deleted, as shown below:
But when I add two or more data, the delete will prompt a few times. Whether to confirm deletion.
After investigation, the problem is finally found.
When dynamically adding content, the events that need to be used on these DIVs are typically written, such as Click event / chang events, and the like. Take my delete event as an example. Since the delete event must be written under the event of the additive, then when the first data is added, the second occasion is binds, the second occasion is binds once, and the nth data is added. I have bind N times to delete events, so when I delete the nth data, I will prompt whether N times confirmed deletion.
Since finding the reason for the wrong reason, it is better to solve it. Before the binding delete event, you can unless the last binding event is. Code:// Solution $ (“. Deletebtn”). OFF (“click”; $ (“. Update”). OFF (“change”); // Bind $ (“. deletebtn”). Bind (‘Click’, delete_click; $ (“. Update”). Bind (‘Change’, Change_Fonts);
Reply to everyone in time!