0

I try to position dialog boxes of Jquery ui with strict locations on website. I try to use them as little pop ups, goes around for a sec then repop them up at different location. However when I scroll my page, dialog boxes follow my viewport. I used this code to position them:

$("#bubble").dialog("option", "position", [xLoc,yLoc]);

Is there any way to give them strict locations?

Here you can check my website that I try on it. When you scroll down popups follow you :(

4

2 に答える 2

2

Per jQuery UI Dialog's docs the position option displays the dialog relative to the user's viewport.

Therefore if you don't want this functionality you should just re-position the dialog by altering the value of its top and left CSS values. This will position the dialog in the top left corner of the screen regardless of the viewport.

$('.ui-dialog').css({
    top: 0,
    left: 0
});
于 2012-05-18T17:03:24.953 に答える
1
$('your_selector').dialog({
  open: function(){
    $('.ui-dialog').css({
        "position": "absolute",
        "top": ( $(window).height() - $(this).height() ) / 2+$(window).scrollTop() + "px",
        "left": ( $(window).width() - $(this).width() ) / 2+$(window).scrollLeft() + "px"
    });
  }
});

i know it was somewhere added in some post, sorry for re-adding, but this should work

于 2013-04-22T14:32:05.783 に答える