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

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

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

html - jQuery UI Sortable - Remove placeholder after item is dropped -