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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -