Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
jQuery confirm dialog using Bootstrap
* jQuery confirm modal using bootstrap 3.0 (might work with other, shrug)
* Usage:
* var otherFunction = function(){
* funkyDialogBox(
* "Will you marry me",
* function(){ console.log('She said YES! :D'},
* function(){ console.log('She said no :(')
* }
* }
var funkyDialogBox = function(message, confirmCallback, cancelCallback) {
var unbind = function(){
$('#dataConfirmModal').unbind('', wrapperCancel);
var wrapperConfirm = function(){
if (typeof confirmCallback !== 'undefined')
var wrapperCancel = function(){
if (typeof cancelCallback !== 'undefined')
if (!$('#dataConfirmModal').length) {
$('body').append('<div id="dataConfirmModal" class="modal fade"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true&times;</span></button><h4 class="modal-title">Please Confimt</h4></div><div class="modal-body text-center"><p>Er du sikker?</p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button><button type="button" id="dataConfirmOK" class="btn btn-primary">Confirm</button></div></div></div></div>');
$('#dataConfirmModal').on('', wrapperCancel);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment