Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery ui dialog dragging issues

I used the jQuery ui (jquery-ui-1.10.3) dialog pluggin for one of our products, and found a possible "problem": When the hosting page is small or the current view of the hosting page is scrolled to the top, dragging an openned dialog box behaves as what is expected. The problem start to manifest when hosting a dialog in a large page which is scrolled to somewhere not at the top, in which case the dialog box starts to jump around during dragging. It happens to both IE 9 and the latest Firefox (21.0).

The page is dynamically generaed, complex and has to be long. I am not familiar with fiddle, but it seems to have no option for jQuery-ui lib option that I can use.

More specifically, I found if I scoll the hosting page 100px down (so the top 100px of the hosting page is 'feed' into the top border of the browser window) then when I drag the dialog, instead of it following the mouse, it jumps down 100px so that it is out of the mouse capture.

The dialog is initiallized as

$(element).dialog({ 
    autoOpen: false, width: 950, height: 820, 
    modal: false, resizable: true, draggable: true
});

My questiong is: 1) does any one else has the same issue? 2) If so, is this an setting issue or a bug.

Any expert here can help me with it?

like image 223
SFD - jinan Avatar asked Jun 22 '13 05:06

SFD - jinan


3 Answers

I used to have the same issue, content on the page is generated automatically. It is very long.

html, body {position: relative} solves the problem.

like image 85
robert Avatar answered Nov 20 '22 17:11

robert


OK, I found this is a bug of jQuery-ui 1.10.3, see here:

That appears only with using UI 1.10.3 and when the scrollbar is not at the very top in Firefox, Opera, IE8.

In Chrome works fine and also with 1.10.2 on other browsers.

The UI dialog demo page has this bug too:

drag the dialog down until appears the scrollbar scroll down again drag the dialog down. dialog goes down with the offset

like image 23
SFD - jinan Avatar answered Nov 20 '22 18:11

SFD - jinan


My solution to fix this bug is similar to that of Dado, but using the drag event:

        $(element).dialog({
            draggable: true,
            drag: function(event, ui) {
                var fixPix = $(document).scrollTop();
                iObj = ui.position;
                iObj.top = iObj.top - fixPix;
                $(this).closest(".ui-dialog").css("top", iObj.top + "px");
            }
        });

My version: jQuery UI - v1.10.3 - 2013-10-10

like image 6
Grimalt Santiago Avatar answered Nov 20 '22 17:11

Grimalt Santiago