views:

16

answers:

1

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?

A: 

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

the_drow
not yet, I'll give a try. thanks
Roland Soós
Thank you, this is exactly what I need!
Roland Soós
@Roland Soós: You are at most welcome, please upvote as well
the_drow