2013-08-16 41 views
0

我有一个jquery对话框,我正在显示一个DIV的内容。但问题是,无论何时单击链接按钮作为链接按钮也出现在页面的底部,但我希望它出现在页面的顶部,以便用户不会出现在页面底部必须向下滚动才能找到对话框。如何将jquery对话框的位置更改为中心?

这里是我的aspx代码:

<a href="#" onclick="OpenDialog('#divNominees','Add Nominee')"> 

jQuery代码:

function OpenDialog(obj,title) { 
    $(obj).dialog({ title: title, modal: true }) 
    $(obj).parent().appendTo($("form:first")); 
    var p = $(obj).parent(); 
    } 

我最欣赏的,如果有人帮我出这一点,因为我已经浪费了整整一个上午来解决这个问题。

在此先感谢。

回答

1

你保持你的DIV嵌套不与其他表/ div的或什么。在下面的示例中,tblOuter是我希望对话框居中的表的ID。

$("#divNominees'").dialog({ 
      modal: true, 
      position: { my: "center", at: "center", of: $("#tblOuter") }, 
      title: "Nominees", 
      dialogClass: "ui-dialog-content" 
     }); 
+0

谢谢你这么much..now它只是工作,我想...ür是天才.. – barsan

0
once try with add css 
margin:0 auto; 

or only auto. 
+0

感谢答复.. – barsan

0

Documentation

$('my-selector').dialog('option', 'position', 'center'); 
+0

感谢您的答复,但这个没有帮助我的问题.. – barsan

相关问题