Code

Re-select bootbox.js modal and close

Let’s say that you have instantiated a bootbox.js modal or dialog somewhere else in your code like this:

bootbox.dialog({
                title: 'Some Title',
                message: 'Hey a popup!',
                className: "hey-modal"
              });

Now you want to take some action on it, like closing it for example. In order to re-select the object you can either use the class name that you gave it or use an element inside the bootbox and traverse the parents until you find “.bootbox”.

jQuery(".hey-modal").modal("hide");

OR

jQuery(".some-element").parents(".bootbox").modal("hide");

 

One thought on “Re-select bootbox.js modal and close

Comments are closed.