On some change events, orentation fires before a real resize event. Do not recommend using the orientation change event when you need to know when the size of the form changes.
Just use $ (window) .resize (function () {stuff to do})
If you need to have dynamic resizing and resizing at some point, you can use this structure
function ResizeEventHandler (){ var resizeEvent = function(){} this.ResizeEvent = function(value){ if (value!=null) resizeEvent = value; else return resizeEvent() } } var ResizeEventHandlerInstance = new ResizeEventHandler(); $(window).resize(function(){ ResizeEventHandlerInstance.ResizeEvent(); }); function YourDinamicalEventSetterFunction(){ ResizeEventHandlerInstance.ResizeEvent(function(){ alert('resized'); }); }
basically, when you need to change the resize event -> change ResizeEventHandlerInstance ... and you will not need to turn off the event all the time when you want to change it.
Janis Rudovskis
source share