Refresh on page when giving resize

Asked

Viewed 414 times

0

I have my function to resize,

    function resizeGrid() {
      $(".divGrid").css("height", ($(document).height() - 325) + "px");
    }
    $(resizeGrid);

It works as I’d like, but when testing in the browser, I always have to give F5 to it to work,?

1 answer

2


There are several possible ways. These are a few:

Via DOM

window.onresize = function(event) {
    resizeGrid();
};

Via Event Listener

window.addEventListener('resize', function(event){
    resizeGrid();
});

Via jQuery

$(window).resize(function() {
    resizeGrid();
});
  • Onosendai, he even calls the function, but to see visually, I have to give F5

  • @Rod You would have an example reproducing this behavior?

  • I put a Location Reload also in resize, there it works, I do not know if it is a good...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.