Search code examples
javascriptjquerybootbox

How to prevent bootbox modal from closing by clicking on a button?


I add a button in the footer and I don't want that the modal close when I click on it. I tried preventDefault but it doesn't work..

dialog.find('.modal-footer').append('<button type="button" class="btn btn-primary">Display</button>')

I use bootbox.

Thank you.


Solution

  • I found the solution. I added the button like this.

    buttons: {            
            success: {
                label: "Display",
                className: "btn-primary",
                callback: function () {
                    return false;
                }
            }
    

    return false

    in callback prevent the closing.

    Thank you.