jquerydom-eventswindow-resizegoogle-closure

goog.event.listen resize event not received from jquery


I use a JS library (GoXTK.com). It uses goog.event.listen to resize a canvas if needed:

goog.events.listen(window, goog.events.EventType.RESIZE, this.onResize_,
      false, this);

It works well if I modify the size of my window with my mouse.

However, sometimes I just want to trigger this callback without actually resizing the window. To do so, I want to use jQuery:

$(window).resize();

In this case, the goog callback is not triggered again.

Any help would be greatly appreciated.

Thanks


Solution

  • Try to dispatch event:

    var ev = document.createEvent('Event');
    ev.initEvent('resize', true, true);
    window.dispatchEvent(ev);