jquery - Where to put off()? -


i have common.js file use , have ajax function form submits i'm not sure put off() handler. go within submit handler or outside of it? i'm trying avoid duplicate form submits.

this have:

$(function () {      $("body").on("submit", "form[data-ajaxform]", function (e) {          e.preventdefault();          /* handle ajax post */       });   }); 

you can use off() directly after submit below:

$(function () {      $("body").on("form[data-ajaxform]", "submit", function (e) {            /*submit should in second param can submitted*/          e.preventdefault();          /* handle ajax post */        // use off here          $(this).off("submit");//after submission of form no more submitted       });   }); 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -