jQuery UI dialog: vertical scroll works not correct if dialog height more than window height

后端 未结 2 901
无人及你
无人及你 2021-01-05 23:42

Here is code:



        
相关标签:
2条回答
  • 2021-01-06 00:32

    A clean solution would be like this one:

    http://jsfiddle.net/4fc33/6/

    What I'm doing is wraping the jQuery UI overlay create method to turn off the event that prevents scrolling to work correctly.

    0 讨论(0)
  • 2021-01-06 00:45

    An alternative approach to not being able to use the window's sliders is to enable sliders on the dialog window, itself. These will show up automatically if you place a cap on the maximum height of the dialog but can be a little tricky with some versions of jQueryUI.

    At least on the version of jQueryUI that I am on (1.9) I needed to specify the maximum height on my own because the maxHeight property that should be able to be used according to the documentation didn't work*.

    Here's what worked:

    $("#dialog").dialog({
        modal: true,
        width: "auto",
        height: "auto"
        /* maxHeight: whatever won't work, */
    }).css("maxHeight", window.innerHeight-120);
    

    I subtracted 120 pixels off of the window's height to accommodate for the Dialog window's header -- and footer section with its "ok" button.

    * The max-height actually would take affect if the dialog was attempted to be resized -- but not upon display.

    0 讨论(0)
提交回复
热议问题