Roland Soós
Roland Soós

Reputation: 3280

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?

Upvotes: 2

Views: 216

Answers (1)

the_drow
the_drow

Reputation: 19181

Have you tried reading about dojo.hitch()?
It deals exactly with those kind of problems.

Upvotes: 3

Related Questions