jQuery UI对话框始终位于右上角

我试图将对话框放在锚标签的右侧,但没有运气。 我在jQuery UI对话框定位检查了解决方案,似乎都没有用。
function openDialog(row_index) {
   var target = $('#note'+row_index);
    $("#dialog_content_"+row_index).dialog({ width:150 },
                                        { height:80 }).dialog('widget').position({
                                                                      my: 'left',
                                                                      at: 'right',
                                                                      of: target
                                                                     });
}
而这个HTML
<a id="note10" onclick="openDialog('10')" style="cursor:pointer">0010</a>

<div style="display:none" title="Title 10" id="dialog_content_10">Row 10</div>
    
已邀请:
将顶部标识添加到my和at属性似乎可行 - 假设您要对齐锚点的顶部和右侧(在Chrome 11.0.6和IE9中测试):
function openDialog(row_index) {
   var target = $('#note'+row_index);
    $("#dialog_content_"+row_index).dialog({ width:150 },
                                        { height:80 }).dialog('widget').position({
                                                                      my: 'left top',
                                                                      at: 'right top',
                                                                      of: target
                                                                     });
}
这是用于测试不同位置的jQuery页面。 编辑: 这是一个小提示,显示它在右边对齐...也许问题是你的CSS或HTML中的其他地方?正如在小提琴中我一直在使用jQuery 1.5.1,jQuery UI 1.8.9和基本主题CSS文件进行测试。     
OOpps - 我的兄弟正在使用我的电脑,我提交了解决方案,而不是我自己 懒惰的方式
//get reference to the element
var target = $('#note'+row_index);

//add an empty span at the very end of the element [only once]
if($('#note'+row_index+'_getPosition').length==0){ 
  $(target).after('<span id="note'+row_index+'_getPosition"></span>')
  }

// get position of newly inserted span
var position = $('#note'+row_index+'_getPosition').position();

//finally call the dialog using position as below
position : [position.left,position.top]
    
懒惰的方式
//get reference to the element
var target = $('#note'+row_index);

//add an empty span at the very end of the element [only once]
if($('#note'+row_index+'_getPosition').length==0){ 
    $(target).after('<span id="note'+row_index+'_getPosition"></span>')
    }

// get position of newly inserted span
var position = $('#note'+row_index+'_getPosition').position();

//finally call the dialog using position as below
position : [position.left,position.top]
    

要回复问题请先登录注册