This was another instance of "Found the solution after posting the question"... this question helped me solve it:
jQuery click events firing multiple times
What I had to do whas this:
$('body').off().on('click', '.edit, .cancel', function(e)
{
e.preventDefault();
// Do something here...
});
You see the off()
there before the on()
. This guarantees that only one click
event is bound to the element.
This answer sheds some light on the issue.
You see: each time the on
event handler is run it attaches another handler for the element and that's why every time I closed/removed the dialog and then reopened/recreated it it would attach as many event handlers as the number of times the dialog was opened. :)