Search code examples
javascriptdojoc3

Trigger window resize event with dojo


I would like to find a way to trigger the window resize event (the one fired when you resize the window of your browser) using Dojo. It will allow me to resize my C3 Charts.

I found the module on allowing to listen and trigger custom events with the function emit, so here is what I tried :

on.emit(win, 'resize', {bubbles: true, cancelable: true});

Where win is the dojo/_base/window module that I tried to use as the source of the fired event. I also tried this :

on.emit(win.body(), 'resize', {bubbles: true,cancelable: true});

But nothing is working, my charts are not receiving the event.


Solution

  • Use the plain window object:

    on(window, 'resize', function() { console.log('resize!')});
    on.emit(window, 'resize', {bubbles: true,cancelable: true})