Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a non-modal bootstrap dialog box

I am trying to create a non-modal bootstrap dialog box. I just don't know how to do it. I have checked lot of post but none answers my question. I need the dialog to be none - modal because I want the user to be able to do other things even if the dialog box is opened.

I saw a link https://snippet.run/x657 but when I tried it, didn't work for me. The dialog refused to open

Thanks a lot.

like image 531
user3576600 Avatar asked Sep 04 '14 16:09

user3576600


3 Answers

Based on the docs this doesnt appear to be possible - however an alert might serve your purposes: http://getbootstrap.com/javascript/#alerts The alert can be put into a div that has a fixed positioned to keep them visible and independent of the content beneath them.

Fiddle

The html:

<button id="myBtn">show 'modal' alert</button>

<p>
  more content that the user should be able to see....
</p>
<p>
  more content that the user should be able to see....
</p>
<p>
  this is the bottom
</p>

<div style="position:fixed;bottom:0;left:0;width:100%;" id="alerts"></div>

and the JS to add the 'modal' alert (which you can style however you like):

$("#myBtn").click(function() {
    $('<div class="alert alert-success alert-dismissable">'+
            '<button type="button" class="close" ' + 
                    'data-dismiss="alert" aria-hidden="true">' + 
                '&times;' + 
            '</button>' + 
            'modal info...' + 
         '</div>').appendTo("#alerts");
}); 
like image 104
pherris Avatar answered Oct 02 '22 05:10

pherris


Just execute the following line once the modal is shown

$(document).off('focusin.bs.modal');

By example :

$("#my-modal").on('shown.bs.modal',function(){
    $(document).off('focusin.bs.modal');
});
like image 27
Vincent Avatar answered Oct 02 '22 06:10

Vincent


You want the user to be able to do other things even if the dialog box is opened , try to inspect element that dialog box .You will notice a div with class "modal-backdrop in" is being applied just before this dialog box div . Due to this class only the body content seems to freeze and you won't be able to click anywhere else in the document body .Remove this class and let user click anywhere and do whatever he wants in the DOM element .

like image 26
Tushar Raj Avatar answered Oct 02 '22 05:10

Tushar Raj