0

I am trying to resize a div with jquery and have the alsoResize trigger: I tried changing the width and then triggering the resize event, but it doesnt work.

fiddle: http://jsfiddle.net/Ns3yn/2/

Thanks!

11
  • What's not working? Looks right to me. Commented Dec 6, 2011 at 15:07
  • The picture isnt being resized (updated fiddle to make it more clear) Commented Dec 6, 2011 at 15:09
  • you're declared the resizable correctly, as you can see when you use the mouse to resize. The way you're trying to trigger it programatically doesn't work. Commented Dec 6, 2011 at 15:20
  • @BZink why does the width() function not fire a resize event ? i would have thought it should work without the trigger('resize') ? Commented Dec 6, 2011 at 15:23
  • Found my answer -> stackoverflow.com/questions/229010/… resize doesnt work on DIVs - works on Windows / Frames ... this is why its not working Commented Dec 6, 2011 at 15:24

3 Answers 3

2

This issue is an interesting one. My need required me to resize many "alsoResize" objects along with resizing the original object.

For one, it is a requested jQuery UI feature:
Resizable: Expose an API for programatically triggering a resize

But, until that is implemented, in lieu of creating this feature myself, I have found a pretty decent quick solution. The solution comes from here:
Programmatically Resize a resizable element


The solution uses some jquery unit testing libraries that simulate a mouse drag. You can find the necessary libraries here:
jquery.simulate.js
resizable_test_helpers.js


So include those two files above, then you can run code like this:

var handle = ".ui-resizable-se";
TestHelpers.resizable.drag(handle, 50, 50);

This will programatically resize your object by 50 pixels right and down.

Sign up to request clarification or add additional context in comments.

1 Comment

I think it's actually the best solution for unit testing resizable event.
0

Because nowhere says that the resizable plugin use the resize event to trigger changes. All you need is add .add('img') after window selector to have the expected result

1 Comment

thats not the point, the point is seperating the code which resizes all the subelements and the code that resizes the whole
0

.trigger("resize") doesn't actually trigger the resize event.

If you bind explicitly to the event you'll see this...

$(".window").bind("resize", function(){
   alert("resize event");

});

1 Comment

seems that you're incorrect: jsfiddle.net/Ns3yn/7 To be more specific, as I read in the doc: divs can still receive the event if they are manually triggered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.