jQuery UI dialog box not positioned center screen

后端 未结 23 3068
失恋的感觉
失恋的感觉 2020-12-01 00:31

I have a jQuery dialog box that is meant to position in the middle of the screen. However, it seems slightly off-center vertically.

Here is the code:

         


        
23条回答
  •  失恋的感觉
    2020-12-01 01:36

    None of the above solutions worked for me. I will present below my scenario and the final solution, just in case someone has the same problem.

    Scenario: I use a custom jQuery plugin to add a scroll bar to an HTML element that is located inside the Dialog box.

    I used it as

    $(response).dialog({
     create: function (event, ui) {
      $(".content-topp").mCustomScrollbar();
     })
    });
    

    The solution was to move it from create to open, like this:

    $(response).dialog({
     open: function (event, ui) {
      $(".content-topp").mCustomScrollbar();
      $(this).dialog('option', 'position', 'center');
     })
    });
    

    So, if you use any custom jQuery plugin that manipulates the content then call it using the open event.

提交回复
热议问题