Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created December 19, 2016 14:55
Show Gist options
  • Select an option

  • Save YurePereira/17f67b53459dd87e41e4a39a5e0a8aeb to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/17f67b53459dd87e41e4a39a5e0a8aeb to your computer and use it in GitHub Desktop.
Modal with bootstrap
var MyModal = (function() {
var alert = function(options) {
var modalConfirm = $('#modal_alert'),
titleModal = modalConfirm.find('.title-modal')
messageModal = modalConfirm.find('.message-modal'),
buttonOk = modalConfirm.find('.model-button-ok');
titleModal.text(options.title);
messageModal.text(options.message);
buttonOk.text(options.buttonNo);
if (options.open) {
modalConfirm.modal('show');
} else {
modalConfirm.modal('hide');
}
};
var confirm = function(options) {
var modalConfirm = $('#modal_confirm'),
titleModal = modalConfirm.find('.title-modal')
messageModal = modalConfirm.find('.message-modal'),
buttonYes = modalConfirm.find('.model-button-yes'),
buttonNo = modalConfirm.find('.model-button-no');
titleModal.text(options.title);
messageModal.text(options.message);
buttonYes.text(options.buttonYes);
buttonNo.text(options.buttonNo);
buttonYes.click(function() {
options.callbackYes(modalConfirm);
});
if (options.open) {
modalConfirm.modal('show');
} else {
modalConfirm.modal('hide');
}
};
return {
confirm: confirm,
alert: alert
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment