2010-03-20 10 views
9

Czy istnieje sposób ustawić wiele asResizes w jQuery UI?jQuery resizable() i wiele równieżResizes?

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

Chciałbym ustawić jeszcze kilka innych elementów, a nie tylko jeden. Oficjalna dokumentacja nic nie mówi.

Odpowiedz

15

spróbować

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

+1

To nie działa, jeśli dasz mu kolekcję jQuery: 'alsoResize: $ (" .inne, .another, .andmanymore ")' co jest niefortunne, jeśli masz widok podobny do kręgosłupa i nie chcesz zmień rozmiar wszystkiego na stronie (na przykład, chcę użyć 'this. $ (" .inne, .inother, .andmanymore ') ') Kod jQuery UI wydaje się unikać tego całkowicie –

+0

thats ponieważ' this' nie jest jQuery element możesz zrobić '$ (" .inne, .another, .andmanymore "). add (this)' zamiast lub odwrotnie lub perhasp '$ (this) .find (" .inne, .another, .andmanymore ") ' – Val

+0

@CalebHearon, a także nie zapomnieć o ograniczeniu: http://api.jqueryui.com/resizable/#option-containment – Val

0

można to zrobić poprzez połączenie div s.

var foo = $('.foo').attr('id'); 
var bar = $('.bar').attr('id'); 
var bar = $('.bar').attr('id'); 
var alsos = '#' + foo + ', #' + bar; 


$('.selector').resizable({ 
alsoresize:alsos, 
}); 
0

Jeśli masz odniesienie do obiektu można użyć tak:

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

można przekazać w tablicy ciągów tak:

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

Te ciągi powinny reprezentować selektorów. Możesz również zmienić rozmiar według klasy lub identyfikatora.