2012-01-27 64 views

回答

2

我認爲你正在使用的版本是不是最新的。您應該檢查GitHub repository這是官方存儲庫的源代碼。

從GitHub的版本使用jquery.ui.position從jQuery用戶界面,它允許你指定要顯示菜單相對的元素(「頂頂層」,「左下」 ......),還允許碰撞檢測

documentation

When the positioned element overflows the window in some direction, move it to an alternative position. Similar to my and at, this accepts a single value or a pair for horizontal/vertical, eg. "flip", "fit", "fit flip", "fit none".

所以,你想用的插件是這樣的:

$('#myelement').selectmenu({ 
    ... 
    position: { 
     my: "left top", // default 
     at: "left bottom", // default 

     // "flip" will show the menu opposite side if there 
     // is not enough available space 

     collision: "flip" // default is "" 
    } 
}); 

檢查_refreshPosition()似乎不再存在以下question了類似的問題解釋(方法原樣但是選項的位置當然仍然存在)。

+0

嗨,當我使用新的jquery.ui.select.js我得到這個錯誤:jquery.ui.select.js:46 - 未捕獲TypeError:對象#沒有方法'_bind' - 在我的第一篇文章中我有添加我的JS。 – Maanstraat 2012-01-27 10:59:16

+0

插件基於jQuery UI 1.9(仍在開發中),其中Widget Factory實現'_bind()'方法。你必須使用jQuery UI 1.9。 – 2012-01-27 11:04:18

+0

當我使用這個版本的時候,會不會工作?因爲我使用更多插件的UI ... – Maanstraat 2012-01-27 11:13:10