javascript - How to prevent child event from firing in JQuery -


so have button

<input id="expandbutton" type="submit" value="expand" class="loadwindow"/> 

i have 2 event handler attached.

function confirmcontinue() {      return confirm("do want expand window, might reload information?"); }  $("input.loadwindow").click(function(event) {       showprocessingwindow(event); }  $("#expandbutton").click(function(event) {      var result = confirmcontinue();      if (!result) {           event.preventdefault();           event.stoppropagaton();      } } 

i want prevent "input.loadwindow" click event firing if cancel.

this happening right now. button clicked --> confirmation fire --> click cancel --> show processing window still fires.

i want button clicked --> confirmation fire --> click cancel --> nothing.

it looks event.stopimmediatepropagation() work in case.

$("#expandbutton").click(function(event) {      var result = confirmcontinue();      if (!result) {           event.preventdefault();           event.stopimmediatepropagation();       } } 

fiddle demo- http://jsfiddle.net/w2vwn35x/1/


Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World