Catch event click on button inside a modal created by jquery -
this question has answer here:
im trying add more feature in zabuto calendar. modal appear after click on date, allow add or remove event day. can't catch event click on button in modal. here code.
function createmodal() { // create modal //... var $modalfooterbuttonsave = $('<button id="btnsave">save</button>'); var $modalfooterbuttondelete = $('<button id="btndelete">delete</button>'); //... //return modal } function mydatefunction() { //add modal html page $("#mymodal").html(createmodal()); //show modal $('#adjustmodal').modal('show'); return true; } $(document).ready(function () { // zabuto event click on date $("#my-calendar").zabuto_calendar({ action: function () { return mydatefunction(); } }); //here problem, can't catch event click on button. $("#btnsave").click(function(){ alert("the btn save clicked."); }); }
use instead:
$(document).on('click', '#btnsave', function(){ alert("the btn save clicked."); });
Comments
Post a Comment