javascript - Alert Showing Twice Modal Bootstrap -


i meet trouble when want pass parameters modal , when modal submited modal showing alert parameter. , im use modal more once , in first event normal when second event parameters first event still show. how solve it

function edit(id) {     var url = "<?php echo base_url() ?>admincontroller/edit";     alert(id + url);     modal(id, url); } function delet(id) {     var url = "<?php echo base_url() ?>admincontroller/delet";     alert(id + url);           modal(id, url); }  function modal(id, url) {  $("#verficationuser").modal('show');     $("#passwordverify").submit(function(e){        e.preventdefault();        alert(id, url);    });  } 

here go mate. whats happening modal function each time modal function called submit event gets binded button called multiple times.

so solution unbind , bind again. fiddle here

use

 function modal(id, url) {  $("#verficationuser").modal('show');   $("#passwordverify").unbind('submit').submit(function(e){    e.preventdefault();    alert(id, url);  });  }   

instead of

function modal(id, url) {  $("#verficationuser").modal('show');     $("#passwordverify").submit(function(e){      e.preventdefault();      alert(id, url);    });  } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -