Permalink
Browse files

returning DOM element from dialog method, adding hideAll method

  • Loading branch information...
1 parent 1bf118d commit 0f81f4d8972e93fdf9bbf09c05f658cf1db4d9c8 @makeusabrew makeusabrew committed Nov 6, 2011
Showing with 19 additions and 2 deletions.
  1. +11 −0 demo.html
  2. +8 −2 js/bootbox.js
View
@@ -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 -->
@@ -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>
View
@@ -28,7 +28,7 @@ var bootbox = bootbox || (function() {
break;
}
- that.dialog(str, {
+ return that.dialog(str, {
"label": label,
"callback": cb
}, {
@@ -75,7 +75,7 @@ var bootbox = bootbox || (function() {
break;
}
- that.dialog(str, [{
+ return that.dialog(str, [{
"label": labelCancel,
"callback": function() {
if (typeof cb == 'function') {
@@ -207,6 +207,12 @@ var bootbox = bootbox || (function() {
});
$("body").append(div);
+
+ return div;
+ }
+
+ that.hideAll = function() {
+ $(".bootbox").modal("hide");
}
return that;

0 comments on commit 0f81f4d

Please sign in to comment.