views:

67

answers:

1

I'm resizing something inside a tab. I want to also resize a different element in the same tab. However, selecting that element is relatively slow, using :visible to figure out which tab panel is visible, and so on. I want to cache the selection, but how? Does alsoResize even accept an object?

// The actual selection is more complex than this
var resizethis = $("#tabs panel:visible div.class2");

$("#tabs div.class1").resizable({ 
  alsoResize: resizethis
});

$("#tabs").tabs({
  show: function(event, ui) { 
    resizethis = $("#tabs panel:visible div.class2");
  }
});

The above code clearly doesn't work, the var changes for resizethis when I change the tab is out of scope for the resizable.

What do I do? Is there any way to cache? Thanks.

A: 
  • AFAIK alsoResize also accepts objects

You can change the element which should also be resized via the post-init syntax.

$('#tabs div.class1').resizable('option', 'alsoResize', resizethis);
jitter
Fantastic, thanks.
Jourkey