Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Bootstrap modal popup button calling multiple times?

I created bootstrap confirm popup, when I click bootstrap ok button on confirm modal then ok button call itself twice or more instead one call, issue is AJAX call for delete is executing multiple times.

My confirm button click jQuery code,

$("#btnOk").on('click', function (e) {
        e.preventDefault();
         $.ajax({
            //ajax call for update/delete
        });
        $('#bsModel').modal('hide');
        $('#bsModel').data("modal", null);
  }); 

Answers


Try following code with model initialization that will remove click old referances

$("#bsModel button").off("click"); 

Or add off("click") with your event

$("#btnOk").off("click").on('click', function (e) {
        e.preventDefault();
         $.ajax({
            //ajax call for update/delete
        });
        $('#bsModel').modal('hide');
        $('#bsModel').data("modal", null);
  }); 

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.