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
Post a Comment