I'm usng jBox url : http://stephanwagner.me/jBox .
and creating a modal every time on click of a link. when the modal is created for the first time, listeners for buttons on that created modal are getting added on the "onCreated" attribute. These listeners are getting attached for 1st time properly and working when those buttons are clicked. From the second time, the listeners are not working. its like dummy button with no listeners.
please find the code sample here. http://jsfiddle.net/sedhuait/4zdavzap/2/
$('#btn').click(function () {
var title = "Create Group";
var createGroup = '<section class="container-fluid"> <div class="form-group col-lg-7"> <button id="btn-create-group" class="btn btn-custom btn-lg btn-block" data-i18n="menubar.group"> ' + title + ' </button> </div> <div class="form-group col-lg-5"><button id="btn-create-group-cancel" class="btn btn-cancel btn-lg btn-block" data-i18n="menubar.group"> Cancel </button> </div> </div> </div> </section>';
var myModal = new jBox('Modal', {
title: title,
content: createGroup,
width: 400,
onCreated: function () {
alert("in on created ");
$('#btn-create-group-cancel').click(function () {
alert("in on cancel ");
myModal.close();
});
$('#btn-create-group').click(function () {
myModal.close();
alert("in on create ");
});
}
});
myModal.open();
});