2013-06-21 102 views
0

如何設置jQuery UI對話框的位置。當我在我的表格點擊finish對話框的位置是在頁面的頂部..jquery ui對話框位置

這裏是我如何調用對話框:

  <div id="dialog" style="display: none;"> 
       <h1>Transaction successful!</h1> 
       <br /> 

       <h3>Thank you.</h3> 
      </div> 

    ScriptManager.RegisterStartupScript(this, this.GetType(), "showmessage", "jQuery('#dialog').dialog({ dialogClass: 'no-close', title: 'Registration Successful', autoOpen: true, height: 300, width: 600, modal: true, draggable: true, resizable: false, buttons: { Ok: function() { window.location.replace('Login.aspx'); } } }); ", true); 

請幫助...

回答

0

您可以使用此可選參數POSITION

$(".selector").dialog({ position: { my: "left top", at: "left bottom", of: button } }); 

更多信息請參見http://api.jqueryui.com/dialog/#option-position。基於現有的代碼

編輯例如:

ScriptManager.RegisterStartupScript(this, this.GetType() 
, "showmessage" 
, "jQuery('#dialog').dialog({ 
    dialogClass: 'no-close' 
    , title: 'Registration Successful' 
    , autoOpen: true 
    , height: 300 
    , width: 600 
    , modal: true 
    , draggable: true 
    , resizable: false 
    , position: { my: "left top", at: "left bottom", of: button } //as per the jqueryUI example will need to customize for your needs. 
    , buttons: { Ok: function() { window.location.replace('Login.aspx'); } } }); ", true); 
+0

我怎麼能叫這在我的代碼behind..i沒有爲對話jQuery的函數,而不是我在代碼中調用它背後.. – aianLee

+0

已經更新了我的答案。 – JanR

+0

問題...我將如何設置:「左上方」,位於:「左下方」,是:按鈕?對不起,以前沒有用過這個.. 我試圖這樣做: 位置:{我:'左',在:'左',:按鈕} 當我運行我的代碼時,它不顯示對話框.. – aianLee