In the following example http://jsfiddle.net/anu4nits/449d5j8e/
<input type="text" id="in" /> <input type="button" value="click" id="button" /> $('#in').change(function () { console.log('change event'); dialog.dialog("open"); }); $('#button').on('click', function (e) { console.log('click event'); });
I have attached two events one is onchange event on text and other is click event on button. If I write something in textbox and clicks on button then handler of change event and handler of click event should get executed respectively. But as I am invoking the modal-dialog in the handler of change event, handler of click event is not getting executed, which is expected as modal- dialog won't allow any background activity. But this is only with chrome and mozilla. In IE handler for both the events are getting executed.
I want consistent behaviour for all browsers preferably i dont want click handler execution in IE. I also don't want to put some flag at global level for condition checking. Also I can't detach the event from button as in my application button ID and its handler are generating at runtime. Is there any other way I can stop the execution of click event from the handler of change event.
Click and Change both are separate events and they have their own stack. So you can't stop propagation of one from another as their target element are also different. What you can do is to attach event at their common parent so that you have a common handler for them. There you can set flag and perform what you want.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments