chacham15
chacham15

Reputation: 14251

jQuery-UI resizable, resizing all child elements

I have a div that I want to scale. I am using the jQuery-UI resizable option for this, but it isnt resizing the children, why?

This is the code I use to instantiate it:


$(this).resizable({
    alsoResize: $(this).find('*'),
}); 

The code is deep inside an app so I created a fiddle that should contain the important parts: http://jsfiddle.net/EnK4R/6/

This works with the image tag: http://jsfiddle.net/EnK4R/12/ I just cant figure out why the '*' selector wont work

Upvotes: 0

Views: 3975

Answers (2)

owenmelbz
owenmelbz

Reputation: 6544

here you go. this doesnt seem to resize whole document, checkout the fiddle at bottom

var init = function(){
    $(this).resizable({
        alsoResize: '#'+$(this).attr('id')+' *'
    });
}

init.call($('#window'));

this keeps the code almost as short as yours, and it will work with what ever gets chucked into the init call. enjoy :)

http://jsfiddle.net/EnK4R/4/

Upvotes: 2

IUnknown
IUnknown

Reputation: 22448

first of all fix the window class selector: change it from .window to #window. And use selector string for alsoResize option:

$('#window').resizable({
    alsoResize: '#window *'
}); 

fiddle: http://jsfiddle.net/1stein/EnK4R/

Upvotes: 0

Related Questions