开发者

Dojo: how to use own onMove event (overwrite)

In docs it was said that:

onMove(mover, leftTop, e) called during every move notification; should actually move the node; can be overwritten.

开发者_如何学运维

but no example how to overwrite it (onMove). Can somebody throw several lines of code to show how it works?

Thanks.


You don't point out which dojo JavaScript class that the onMove function belongs to. However, you have a couple of generic ways to override functions that also applies in your case.

1) Create a new subclass using dojo.declare.

Suppose the JavaScript class name is myClass, you can use

dojo.declare('anotherClass', myClass, {
    onMove : function(mover, leftTop, e) {}   
});

2) Change the class's prototype using dojo.extend.

dojo.extend(myClass, {
    onMove : function(mover, leftTop, e) {}         
});

If you only want to override the function for a single instance, set the property directly.

var obj = new myClass();
obj.onMove = function() {};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜