0

I have the following code, which sets the height of a div when the window loads:

$(window).bind("load", function() { 

          var 
           windowHeight = $(window).height(),
           callerPrimaryHeight = $('.caller-primary-nav').outerHeight(),
           callerSecondaryHeight =  $('.caller-secondary-nav').outerHeight(),
           callerFooterHeight = $('.caller-footer').outerHeight(),
           callerHeight = windowHeight - callerPrimaryHeight - callerSecondaryHeight - callerFooterHeight;

           positionCallers();

          function positionCallers() {  
           $('.caller-block').outerHeight(callerHeight);
         }

});

How can I call this function when the window resizes? I know the function is $('window').resize(); but how can I can the positionCallers() function outside of the window load?

alias51
  • 8,178
  • 22
  • 94
  • 166

1 Answers1

0

you can bind multiple events like this:

$(window).bind("load resize", function() {
    //..........all your code here......
}).resize();

but also you need a doc ready handler, put it when dom is ready for your code:

$(function(){
   $(window).bind("load resize", function() {
       //..........all your code here......
   }).resize();
});
Jai
  • 74,255
  • 12
  • 74
  • 103