2010-03-20 33 views
9

有沒有辦法在jQuery UI中設置多個alsoResizes?jQuery resizable()和多個alsoResizes?

$('.selector').resizable({ alsoResize: '.other' }); 

我想設置一些其他元素來調整大小,而不僅僅是一個。官方文件沒有說明什麼。

回答

15

嘗試

$('.selector').resizable({ alsoResize: '.other,.another,.andmanymore' });

+1

如果你給它一個jQuery集合,它不起作用:'alsoResize:$('。other,.another,.andmanymore')'這是不幸的,如果你有類似Backbone的視圖,並且不想調整頁面上的所有內容(例如,我想使用'this。$('。other,.another,.andmanymore')')jQuery UI代碼似乎完全避免了這個問題 – 2013-04-02 14:43:02

+0

這是因爲'this'不是jQuery元素你可以做'$('。other,.another,.andmanymore')。add(this)'而不是反過來或者反過來'$(this).find('。other,.another,.andmanymore' )' – Val 2013-04-02 14:54:41

+0

@CalebHearon,也不要忘記容器:http://api.jqueryui.com/resizable/#option-containment – Val 2013-04-02 14:56:22

0

這可以通過組合的div來完成。

​​
0

如果你有對象的引用,那麼你可以使用這樣的:

$(el).resizable(
     { 
      alsoResize: [ el.children[0], el.children[1] ] 
     }); 
1

你可以在一個字符串數組通過像這樣:

$('.selector').resizable({ alsoResize: [ 
    '.other', 
    '.and-another', 
    '#and-one-more' 
]}); 

這些字符串應該代表選擇。您也可以按類或ID調整大小。