2016-11-24 48 views
0

jQuery PopUp位置不工作。 流行邊框和內容分離。JQuery PopUp位置不工作

嘗試下面的代碼

newDiv = $(document.createElement('div')); 
    $(newDiv).addClass("popup hide-scrol"); 
    newDiv.dialog({ 
     autoOpen: false, modal: true, show: "blind", hide: "blind" 
    }); 
    newDiv.html(response); 
    newDiv.dialog("option", "width", $(".render-body").width() * 0.5); 
    newDiv.position({ 
        my: "center", 
        at: "left", 
        of: ".container" 
        }); 

輸出

enter image description here

回答

0

你試過嗎?

newDiv.dialog("option").position({ 
    my: 'center', 
    at: 'left', 
    of: "#targetElement" 
}); 

和報價的JQuery Ui

的(默認:null)的API文檔

類型:選擇或元素或jQuery的或事件 哪個元素反對立場。如果您提供選擇器或jQuery對象,則將使用第一個匹配元素。如果您提供事件對象,則將使用pageX和pageY屬性。例如:「#top-menu」