0

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.

4

2 回答 2

3

Use the plain window object:

on(window, 'resize', function() { console.log('resize!')});
on.emit(window, 'resize', {bubbles: true,cancelable: true})
于 2015-06-23T13:40:17.493 回答
1
define([
    "dojo/_base/declare",
    "dijit/Viewport"
], function(declare, Viewport) {

    return declare("Som", [Viewport], {
        onClick: function(){
            Viewport.emit("resize");
        }
    });

});
于 2016-06-23T18:59:02.007 回答