javascript - delegated click event not firing when element gets disabled -


when bind click handler element disables element, try delegate event it, second event doesn't fire.

is there simple solution this?

demo

$('button').click(function() {     log('first click fired');     $(this).prop('disabled', true); }); $('span').on('click', 'button', function() {     log('second click fired'); }); 

html:

<span><button>click</button></span> 

edit:

to clarify, setting click event on object fire as seen in edit, want able delegation

disabled elements not fire mouse events, ... wait ... disabled.

since don't fire mouse events, no event bubbles span, , event handler never triggers.

the solution not disable element, , it's pretty solution far know, if explain why need behaviour maybe can workaround?

edit:

it seem work if create own delegation:

$('span').on('click', function(e) {     if (e.target.tagname.tolowercase() === 'button')         log('second click fired'); }); 

fiddle


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -