Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#16763 closed defect (worksforme)

on(window, 'resize', ...) not working

Reported by: Alexander Kläser Owned by: Kris Zyp
Priority: undecided Milestone: tbd
Component: Events Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

As suggested in ticket #15861, I am opening a new one for this problem. Trying to hook to window.onresize event with dojo/on directly on the console does not seem to work using Chrome 24:

on = require("dojo/on")
on(window, 'resize', function() { console.log('window on resize') })

Could it be due to window.onresize being null initially?

Change History (4)

comment:1 Changed 7 years ago by bill

It's strange, it's working in dijit/Viewport.js.

comment:2 Changed 7 years ago by Alexander Kläser

True, dijit/Viewport is working correctly. I think I have it now, using window was wrong, it should be this or dojo/_base/window::global. The following works in the code, however not directly live in the console:

on = require("dojo/on")
win = require("dojo/_base/window")
on(win.global, 'resize', function() { console.log('window on resize') })

comment:3 Changed 7 years ago by bill

Resolution: worksforme
Status: newclosed

Well, glad you have it working. Using window works fine for me, I just typed:

require("dojo/on")(window, "resize", function(){ console.log("got resize"); })

into my chrome/mac console (while running dijit/tests/form/test_Select.html) and resizing the browser window prints the message. Perhaps you redefined the window variable to something else.

comment:4 Changed 7 years ago by Alexander Kläser

Now I understand, window was not the problem, it was on. The following lines are working as expected:

_on = require("dojo/on")
_on(window, "resize", function() { console.log('window on resize') })
Note: See TracTickets for help on using tickets.