how to stop execution of click event from onchange event handler

Ninja

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.

user4223020

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Stop event propagation on click handler

From Dev

How to stop function in event handler

From Dev

Remove click event handler from <a>

From Dev

OnChange event handler not working

From Dev

Not working handler on "onchange" event

From Dev

Not working handler on "onchange" event

From Dev

How to stop multiple event handler onclick on html from servise resnonse?

From Dev

How to create click event handler inside mouseover event handler?

From Dev

AngularJS: How to stop event propagation from ng-click?

From Dev

jQuery how to stop triggered click event from bubbling

From Dev

Exclude elements from click event handler (jquery)

From Dev

Click event not posting to handler

From Dev

TypeScript click event handler

From Dev

JQ event handler on a click

From Dev

AmStockCharts - Click Event Handler

From Dev

Click Event handler

From Dev

TypeScript click event handler

From Dev

How to work with Click Event Handler jQuery

From Java

How to pass a parameter to Vue @click event handler

From Dev

How to pass event and other arguments to click handler

From Dev

How to work with Click Event Handler jQuery

From Dev

React: Cannot set state from onchange event handler on form select

From Dev

Force Stop Click Event

From Dev

Execution of RichTextBox event handler "textChanged"

From Dev

How to stop service on button click event

From Dev

How to stop click event to continous running JQuery

From Dev

How to capture the value of a textbox from an OnChange event

From Dev

How to fire a jquery function onchange from an html element in highchart event on click?

From Dev

How to fire a jquery function onchange from an html element in highchart event on click?

Related Related

HotTag

Archive