#15861 closed defect (invalid)
on(window, 'onresize', ..... not working
Reported by: | daniel.payne | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | tbd |
Component: | Events | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
does not work: on(window, 'onresize', testFunction);
does work: window.onresize = testFunction;
Test Code
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- REMOVE FOR PRODUCTION --> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="pragma" content="no-cache">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> <meta name="apple-mobile-web-app-capable" content="yes" />
<script>
var dojoConfig = {
isDebug: true, parseOnLoad: false, async: true
};
</script>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js"></script>
<script >
require([
"dijit/registry", "dojo/dom", "dojo/parser",
"dojo/on",
"dojo/domReady!"
], function (registry, dom, parser, on) {
parser.parse();
function testFunction(){
};
does not work on(window, 'onresize', testFunction);
if (window.onresize !== null) {
window.alert('on pass');
} else {
window.alert('on fail');
}
window.onresize = testFunction; if (window.onresize !== null) {
window.alert('assignment pass');
} else {
window.alert('assignment fail');
}
});
</script>
</head>
<body >
Test Complete
</body> </html>
Change History (5)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
Component: | General → Events |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Right.
comment:3 Changed 8 years ago by
I just ran into the same problem. The following line would not work in Chrome 24:
on(window, 'resize', function() { console.log('window on resize') })
Could it be due to window.onresize being null initially?
comment:4 Changed 8 years ago by
Usually you have to wait to do commands until dojo/domReady!, but not sure of the rules if you are listening on the window object. If you have a test case that fails you should probably file a new ticket.
comment:5 Changed 8 years ago by
I was testing it live on the console, so the domReady was certainly not a problem. OK, I opened ticket #16763.
I think that the event name should not start with "on", see http://dojotoolkit.org/reference-guide/1.8/dojo/on.html.