2

I am looking into the jQuery UI Resizable method and I have to DIVs (one next to the other). I want to be able to resize one and change the other accordingly. One DIV gets bigger and the other DIV gets smaller...

$(document).ready(function () {
$("#right").resizable({
    alsoResize: '#left',
});

$("#left").resizable({
    alsoResize: '#right',
});

});

Thanks, Max

2 Answers 2

3

You want to tie into the "resize" event (http://docs.jquery.com/UI/Resizable#event-resize)

  $("#right").resizable({
        resize: function(event, ui) { 
          // look at the size of the ui element being resized 
          // and resize the left accordinly        
        }
  });
Sign up to request clarification or add additional context in comments.

Comments

1

It looks okay, but try removing the comma at the end of your array, since you don't have any more array elements.

$(document).ready(function () {
  $("#right").resizable({
        alsoResize: '#left'
  });

  $("#left").resizable({
        alsoResize: '#right'
  });

});

2 Comments

Yes this works however this resizes the left to the same size as the right. I want the left to get smaller by the amount I make the right bigger...
Ah right. I don't think there's an "out-of-the-box" solution, but you could try using the resize event, make it a function which captures the difference of the old and new sizes, than adjust the current element height/width values. I'll try and come up with a code sample.

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.