txominpelu
txominpelu

Reputation: 1067

Ember binding not working

I've been trying to make bindings work in Ember with a really simple example but they don't work properly. It shouldn't be a matter of synchronization since I'm calling Ember.run.sync(). The code that I'm using is the following:

var MyApp = Ember.Application.create();
MyApp.initialize();

MyApp.president = Ember.Object.create({
        name: "Barack Obama"
});

MyApp.country = Ember.Object.create({
      // Ending a property with 'Binding' tells Ember to
      //   // create a binding to the presidentName property.
      presidentNameBinding: 'MyApp.president.name'
});

// Later, after Ember has resolved bindings...
Em.run.sync();
console.log(MyApp.country.get('presidentName'));​

And I've also created a fiddle here.

http://jsfiddle.net/XKsNr/

Upvotes: 1

Views: 401

Answers (1)

Tualatrix Chou
Tualatrix Chou

Reputation: 701

You should declare MyApp without "var", the first line should be:

MyApp = Ember.Application.create();

See more details here: http://docs.emberjs.com/#doc=Ember.Application&src=false

Upvotes: 3

Related Questions