Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Using a compute as a property of a Map

$
0
0
Hi

I'm trying to create a compute as a property of a Map. But I've been unable to correctly combine the two. Any guidance would be appreciated. We're using version canjs 1.1.8 with jquery.


var Contact = can.Map.extend({
    first: "Largo",
    last: "Elks",
    email: null,
    ready: can.compute(function() {
        if (this.attr("first") && this.attr("last") && this.attr("email")) {
            return "ready";
        }
        return "invalid";
    })
});

contact = new Contact();

...

contact.ready();  // TypeError: this.attr is not a function

contact.attr("ready") // undefined



Viewing all articles
Browse latest Browse all 3491

Trending Articles