Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

Ehsan Zargar Ershadi picture Ehsan Zargar Ershadi · Apr 22, 2013 · Viewed 554.2k times · Source

I'm using the Twitter Bootstrap modal as a wizard window, and would like to prevent the user from closing it when clicking outside of the modal or when pressing escape. Instead, I want it to be closed when the user presses the finish button. How could I achieve this scenario?

Answer

Ehsan Zargar Ershadi picture Ehsan Zargar Ershadi · Apr 22, 2013

If using JavaScript then:

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})

or in HTML:

<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">