dojo方面没有定义,不明白为什么 [英] dojo aspect not defined, dont understand why

查看:128
本文介绍了dojo方面没有定义,不明白为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要从dojo 1.7更新到1.8.3,所以我必须更换dojo.connect命令。



switch:

 < div id =universalPushSwitchdata-dojo-type =dojox.mobile.Switchstyle =float:rightclass =mblSwRoundShape1>< / div> 

现在我有:

  dojo.require( 的dijit /注册表); 
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说:方面没有定义



PS:我知道我不使用新的AMD加载程序。这是一个老项目,我也是所有dojo的新东西。从 dojo.require(x); dojo.require(y); require([x, y],function(x,y){...} 对我来说不起作用,所以还有旧样式需要。

解决方案

尝试使用:

  dojo.aspect.after(...); 

而不是

 code> aspect.after(...); 

不要在下一个停止功能!: - )



如果一次不起作用,请尝试以全局方式加载方面(带点,而不是斜杠):

  dojo.require(dojo.aspect); 

也可能是旧的dojo与/不兼容,只有来源:





/ dojo / requirerel =nofollow> http://livedocs.dojotoolkit.org/dojo/require



编辑: strong>



这是一个基于你的小提琴的工作小提琴:



http://jsfiddle.net/9Xdv2/



您代码的主要问题是你没有解析html。
dojo解析器将一些特定的html转换为dojo javascript对象!
你使用这种HTML很多!你应该做一个:

  dojox.mobile.parser.parse(); 

一切都在jsfiddle!



卢西恩


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 !

Lucian

这篇关于dojo方面没有定义,不明白为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆