re-size the modal dialog in bootstrap dynamically

jayeshkv

I have a Modal Popup (Bootstrap) which displays content based on the user selection

This is the javascript code that i've used to check for the users selection

PlayerMP.getFunctionalDetails = function (type, UserID, SessionID, SessionNo) {
$.ajax({
    type: "GET",
    url: PlayerMP.URL,
    data: "rt=4&type=" + type + "&UserID=" + UserID + "&SessionID=" + SessionID + "&SessionNo=" + SessionNo,
    success: function (FunctionalSplitsJS) {
        if (FunctionalSplitsJS.indexOf("SessionExpired=1", 0) == -1) {

            $("#divFunctionalDetails").html(FunctionalSplitsJS);
            switch (type) {
                case 1:
                    $("#divFunctionalsSplit");      //the table goes out of the modal window                           
                     break;
                case 2:
                    TallyFunctionalSheet();
                    $("#divFunctionalsSplit"); 
                    break;
                case 3:
                    $("#divFunctionalsSplit"); 
                    break;
            }                

             $("#divFunctionalsSplit").modal('show');
        }
        else
            window.location.href = "../Login.aspx?SessionExpired=1";
    }
});
}
  • The first case has a table which is supposed to be displayed inside the modal popup but the table goes outside the modal window (there is a problem with the width of the modal window but the table-responsive seem to be working) But when i resize the browser to match the width of the tablet the table/modal auto resizes to match each other.
  • The width of the 2nd and the 3rd case's of the modal seem to work fine.

This is the code for the modal window thats being called

 <div class="modal fade" id="divFunctionalsSplit" tabindex="-1" role="dialog" aria-hidden="true">  
        <div class="modal-dialog">
            <div class="modal-content"> 
                  <div class="modal-body">
                    <div class="table-responsive">
                        <div id="divFunctionalDetails"></div>
                      </div>
                   </div>
                   <div class="modal-footer">
                   <button type="button" class="btn btn-primary" data-dismiss="modal">Done</button>
                   </div>
            </div>
        </div>
 </div>
  • Fullscreen Browser Full screen image
  • Resized Browser Resized Image
Bass Jobsen

By default boottrap sets the width of the .modal-dialog to 600px (large screens above 768 px) or auto (small screens). The code below overwrite this:

$('#myModal').on('shown.bs.modal', function () {
    $(this).find('.modal-dialog').css({width:'auto',
                               height:'auto', 
                              'max-height':'100%'});
});

(based on: https://stackoverflow.com/a/16152629/2260496)

To make it more dynamically you will need to calculate the width (jQuery width() or innerwidth())of your table and set the width of the modal-dialog according it.

See: http://bootply.com/88364

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

re-size the modal dialog in bootstrap dynamically

From Dev

href in modal dialog in bootstrap

From Dev

Validation in bootstrap modal dialog

From Dev

Dynamically output Bootstrap modal

From Dev

Twitter Bootstrap - Center Modal Dialog

From Dev

Using Bootstrap Clockpicker in modal dialog

From Dev

Default button in bootstrap modal dialog

From Dev

Image opens modal dialog bootstrap

From Dev

How can I prevent the closure of my Bootstrap modal dialog when I resize past its maximum size?

From Dev

Make modal-dialog fixed width but when screen re-sizes smaller then it, it must re-size responsive

From Dev

Bootstrap dynamically load div into modal

From Dev

Dynamically build Twitter Bootstrap modal

From Dev

Set Bootstrap Modal text dynamically?

From Dev

Dynamically load modal-dialog in one page

From Dev

How to enlarge the size of modal in bootstrap

From Dev

Bootstrap modal dialog center image in body

From Dev

Not able to access bootstrap modal dialog in Selenium Webdriver

From Dev

Minimize or collapse a bootstrap 2.3.2 modal dialog?

From Dev

PDF file to be displayed on the dialog modal via bootstrap

From Dev

time-picker in bootstrap modal dialog

From Dev

Bootstrap modal-dialog is not getting display

From Dev

Jquery close bootstrap modal dialog completedly

From Dev

Displaying a bootstrap Modal dialog from Angular Controller

From Dev

Unit testing React Bootstrap modal dialog

From Dev

How to show a modal dialog using bootstrap

From Dev

Bootstrap modal-dialog is not getting display

From Dev

Add a confirm bootstrap modal/dialog to checkbox

From Dev

time-picker in bootstrap modal dialog

From Dev

Bootstrap modal dialog set attributes from javascript

Related Related

HotTag

Archive