I am using block ui to block the page and capture some information:
On the message div, I have 2 buttons. OK and Cancel.
If I set the click events on the page load:
$('#title-picker input[name=ok]').click(ok);
$('#title-picker input[name=cancel]').click(cancel);
The events are not triggered after calling $.blockUI
. However if I use the .live
method instead it works as intended.
$('#title-picker input[name=ok]').live('click',ok);
$('#title-picker input[name=cancel]').live('click',cancel);
I assume the mechanism it uses removes and adds the div to the DOM, and this must be what is detaching the original event handlers. I've used earlier versions of block ui before and it hasn't done this. And I can't see anything obvious in the documentation.
So, is my reasoning correct?
And are there any downsides to using .live
, i.e. is there a better workaround to what I have above?