Thursday, 22 June 2017

Bootstrap : Prevent or disable Modal pop up disappearing while outside click or pressing escape ~ GNIITHELP


Problem : I am working with Bootstrap Modal to display pop up window but whenever i click outside the modal or press escape button it goes disappear but i want to manually close it by clicking close button on modal pop up.

Solution : To disable on click set backdrop option as staticand to prevent closing of the modal by esc button set keyboardoption as false as shown in below given code.

1. If you are using javascript for displaying Modal.
$('#myModal').modal({backdrop: 'static', keyboard: false})  

2. If you are using data attributes on html or jsp.
<button data-backdrop="static" data-keyboard="false" data-target="#myModal" 
data-toggle="modal">  
Click Here for Modal  
</button>

No comments:

Post a Comment