Stackers,
I've got a curious case. There is a container element, that contains some other element with the class "clickable". The event listener to clickable 'click' is attached to the container, using delegation.
<input type="text"/>
<div class="container">
<div class="clickable">Click</div>
</div>
$container.on('click', '.clickable', incrementCounter);
There is also an input element outside the container. On 'change' event the content of the container is replaced with the identical one (using $container.html()) on the next event loop turn (to be realistic :-).
$input.on('change', function() {
setTimeout(function() {
$container.html('<div class="clickable">Click</div>');
}, 0);
});
Now the case: enter something in the input field (do not click anywhere or press Enter). Then immediately click on the clickable.
What happens: 'change' event causes the re-rendering of the container on the next event loop turn and the 'click' event is never generated.
It can be solved with replacement of the 'click' event with the 'mouseup'.
Question: why such a difference?
See plunk.