tags:

views:

362

answers:

2

Hi, 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

+1  A: 

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'
  });

});
Acorn
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...
mistero
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.
Acorn
+1  A: 

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        
        }
  });