I want to update from dojo 1.7 to 1.8.3 so I have to replace the dojo.connect command.
switch:
< div id="universalPushSwitch" data-dojo-type="dojox.mobile.Switch" style="float:right" class="mblSwRoundShape1"></div>
Now I have:
dojo.require("dijit/registry");
dojo.require("dojo/ready");
dojo.require("dojox/mobile/ListItem");
dojo.require("dojo/aspect");
dojo.ready(function(){
dojo.aspect.after(dijit.registry.byId("universalPushSwitch"), "onStateChanged",
function(newState){
alert(newState);
}
)});
Firebug says: "aspect is not defined"
PS: I know I don't use the new AMD loader. This is an old project and I am also new to all the dojo stuff. A simple translate from dojo.require("x");dojo.require("y");
to require(["x","y"], function (x,y){...}
doesn't work for me so there is still the old style require.
Try using:
dojo.aspect.after(...);
instead of
aspect.after(...);
And do not stop at the next function ! :-)
If that doesn't work at once, try loading aspect the global way (with a dot, not a slash):
dojo.require("dojo.aspect");
It also could be possible, that the old dojo is not compatible with "/" and that it only works with dots !
Source:
http://livedocs.dojotoolkit.org/dojo/require
Edit
Here is a working fiddle based on your fiddle:
http://jsfiddle.net/9Xdv2/
The main problem with your code was that you did not parse the html. dojo parser converts some specific html to "dojo javascript objects" ! You use that kind of html a lot ! You should have done a:
dojox.mobile.parser.parse();
Everything is in the jsfiddle !
Since you are using dojo 1.8.3 and have been using dojo 1.7, why don't you use the AMD syntax instead of the pre-1.7 ?
You would do something like :
<div id="universalPushSwitch" data-dojo-type="dojox/mobile/Switch" style="float:right" class="mblSwRoundShape1"></div>
And in your js :
require(["dijit/registry",
"dojox/mobile/ListItem",
"dojo/aspect",
"dojo/parser",
"dojo/domReady!"
], function(registry, ListItem, aspect, parser){
parser.parse().then(function(instances){
aspect.after(registry.byId("universalPushSwitch"), "onStateChanged",
function(newState){
alert(newState);
});
});
});