我正在使用Dojo框架来帮助我在Javascript开发中使用交叉浏览DOM操作和事件管理.
为此,我希望在对象之间使用自定义事件调度.但我没有发现任何相关内容.我读到了订阅/发布,但这不完全是我想要的.
这是我想要做的:
var myObject = new CustomObject();
dojo.connect(myObject, 'onCustomEvent', function(argument) {
console.log('custom event fired with argument : ' + argument);
});
var CustomObject = (function() {
CustomObject = function() {
// Something which should look like this
dojo.dispatch(this, 'onCustomEvent', argument);
};
}) ();
Run Code Online (Sandbox Code Playgroud)
有人可以帮帮我吗?
谢谢.