Skip to content

Commit

Permalink
returning DOM element from dialog method, adding hideAll method
Browse files Browse the repository at this point in the history
  • Loading branch information
makeusabrew committed Nov 6, 2011
1 parent 1bf118d commit 0f81f4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ <h2>Custom Dialogs</h2>

<h2>Multiple Dialogs</h2>
<a href="#" class="multiple">multiple</a>

<h2>Programmatic Close</h2>
<a href="#" class="dialog-close">close</a>
</div>

<!-- JS dependencies -->
Expand Down Expand Up @@ -91,6 +94,14 @@ <h2>Multiple Dialogs</h2>
});
}, 1000);
});

$("a.dialog-close").click(function(e) {
e.preventDefault();
var box = bootbox.alert("This dialog will close in two seconds");
setTimeout(function() {
box.modal('hide');
}, 2000);
});
});
</script>
</body>
10 changes: 8 additions & 2 deletions js/bootbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var bootbox = bootbox || (function() {
break;
}

that.dialog(str, {
return that.dialog(str, {
"label": label,
"callback": cb
}, {
Expand Down Expand Up @@ -75,7 +75,7 @@ var bootbox = bootbox || (function() {
break;
}

that.dialog(str, [{
return that.dialog(str, [{
"label": labelCancel,
"callback": function() {
if (typeof cb == 'function') {
Expand Down Expand Up @@ -207,6 +207,12 @@ var bootbox = bootbox || (function() {
});

$("body").append(div);

return div;
}

that.hideAll = function() {
$(".bootbox").modal("hide");
}

return that;
Expand Down

0 comments on commit 0f81f4d

Please sign in to comment.