I have a modal which content is dynamic, and this modal has a reject button.
This modal itself is generated dynamically via a link, so I have to use delegate
$( "body" ).delegate( ".reject", "click", function(e) {
$(".modalInfo").hide();
$(".modalReject").show();
someFunction();
});
Let's say the user click on the reject button and close the modal. Then she loads a new modal, so this modal's context changing and has a new reject button.
The moment user click the reject button again on this new context, somehow someFunction() executed twice - once from the original click, and second one from this new click. Close the modal again, load a new context, execute the click and voila.. got three someFunction() calls!
After some research, this is what I found: When replace element, what happen on the events and data
How to prevent this?