JS
/**
* Dependent File
* bootbox.js
* */
$('.your_element').on('click', function (e) {
e.preventDefault();
// initiate bootbox code here
});
// Initiate Dialog code
bb_demos.dialog = function () {
bootbox.dialog({
message: "I am a custom dialog",
title: "Custom title",
buttons: {
success: {
label: "Success!",
className: "btn-success",
callback: function () {
DemoCallBack.show("great success");
}
},
danger: {
label: "Danger!",
className: "btn-danger",
callback: function () {
DemoCallBack.show("uh oh, look out!");
}
},
main: {
label: "Click ME!",
className: "btn-primary",
callback: function () {
DemoCallBack.show("Primary button");
}
}
}
});
}
// Custom Html Contents
bb_demos.custom_html = function () {
bootbox.dialog({
title: "That html",
message: '<img src="images/avatar/jaman_01.jpg" alt="image"/><br/> You can also use <b>html</b>'
});
}
// Custom Html Forms
bb_demos.html_forms = function () {
bootbox.dialog({
title: "This is a form in a modal.",
message: '<div class="row"> ' +
'<div class="col-md-12"> ' +
'<form class="form-horizontal"> ' +
'<div class="form-group"> ' +
'<label class="col-md-4 control-label" for="name">Name</label> ' +
'<div class="col-md-4"> ' +
'<input id="name" name="name" type="text" placeholder="Your name" class="form-control input-md"> ' +
'<span class="help-block">Here goes your name</span> </div> ' +
'</div> ' +
'<div class="form-group"> ' +
'<label class="col-md-4 control-label" for="awesomeness">How awesome is this?</label> ' +
'<div class="col-md-4"> <div class="radio"> <label for="awesomeness-0"> ' +
'<input type="radio" name="awesomeness" id="awesomeness-0" value="Really awesome" checked="checked"> ' +
'Really awesome </label> ' +
'</div><div class="radio"> <label for="awesomeness-1"> ' +
'<input type="radio" name="awesomeness" id="awesomeness-1" value="Super awesome"> Super awesome </label> ' +
'</div> ' +
'</div> </div>' +
'</form> </div> </div>',
buttons: {
success: {
label: "Save",
className: "btn-success",
callback: function () {
var name = $('#name').val();
var answer = $("input[name='awesomeness']:checked").val()
DemoCallBack.show("Hello " + name + ". You've chosen <b>" + answer + "</b>");
}
}
}
});
}