Dojo 1.4 how to bind an object
Here is my code:
dojo.provide("test.validation");
dojo.declare("test.validation", null, {
addValidate : function(a) {
this.a = dijit.byId(a);
var link = dojo.connect(dijit.byId("form"), "onclick", this.validate);
},
validate : function(e)开发者_开发知识库 {
e.preventDefault();
console.log(this);
if (!this.a.isValid()) {
return false;
}
}
});
I would like call this: this.a.isValid()
function, but I'm out of my object scope.
How can I bind it to that onclick event?
Have you tried reading about dojo.hitch()?
It deals exactly with those kind of problems.
精彩评论