I am looking for a listener to body resize.
I need something similiar to $(window).resize() but for the body.
Why do I need it for the body? I add content using ajax and it might change the body size (depends on user’s resolution).
How can I make body resize listener / where can I find one?
EDIT:
except for the ajax, I got accordion.
each Item has different height and therefore can cause the body to resize…
Thanks.
There is no reliable way to listen for body resize, BUT you can listen for animation occurring in your accordion. There are two ways to do this, but one of them is cooler.
Somewhere in your accordion script you have a jQuery
.animatestatement. If you don’t and are using a shortcut like.show(200)or.fadeIn, you will need to convert it to a.animatestatement. All these commands are really just shortcuts for.animateanyway. If you are usingslideUpandslideDown. You will have to save the height of your elements when the slider is initialized for use later (this is what jQuery is doing behind the scenes btw).Next you will want to use the step property of .animate to listen for the presence of the scrollbar:
But if you want to be cooler, you can add custom events to your widget. This way future development can tie into these events as free functionality.
Now you can tie into your widget’s new event model and listen for animation and scrollbars like so: