using amber with knockoutjs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

using amber with knockoutjs

Chris Zheng
I'm looking forward to using amber, but am unsure of how the 'this' keyword from js is mapped.

Would someone be able to post up a little example of how amber might be able to work with a js framework like knockoutjs. 

The simplest example is on:

http://knockoutjs.com/examples/helloWorld.html

and the Js is:

// Here's my data model
var ViewModel = function(first, last) {
    this.firstName = ko.observable(first);
    this.lastName = ko.observable(last);
 
    this.fullName = ko.computed(function() {
        // Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
        return this.firstName() + " " + this.lastName();
    }, this);
};
 
ko.applyBindings(new ViewModel("Planet", "Earth"));