I know I can do this:
$(window).resize(function() {funkyfunc();});
This will run funkyfunc()
on a window resize.
My problem is that I would like to resize a control once another one has been resized. This doesn't work -- Is there s开发者_C百科omething I am missing or is this simply not possible?
$('#myDiv').parent().resize(function() {funkyfunc();});
The resize
event is only called on window
for resizes to the browser window, it does not exist on individual elements. What would be resizing them, other than your code? If that is the case, then you could get your code to trigger the resize event by calling .trigger('resize')
or somesuch on the element you resize.
There is not a specific javascript event such as resize that you could bind to, but you could you accomplish it by finding what triggers the resize the first control and then manually calling your funkyfunc when that happens. Or you could trigger a custom event when the first control is resized.
For inspiration look at the jQuery resizable stuff:
http://jqueryui.com/demos/resizable/
You will see the option 'alsoResize' which sounds like what you want.
精彩评论