The following code snippet is sourced from the official ember.js introduction:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="ember-0.9.3.js"></script>
<script type="text/javascript">
var App = Ember.Application.create();
App.president = Ember.Object.create({
name: "Barack Obama"
});
App.country = Ember.Object.create({
presidentNameBinding: "App.president.name"
});
App.country.get("presidentName");
</script>
</body>
</html>
I attempted to display the result of
App.country.get("presidentName");
by using an alert, but it consistently showed as undefined
. Interestingly, when I executed this statement in the Firebug console, it correctly displayed as "Barack Obama"
.
The documentation mentioned:
Note that bindings don't update immediately. Ember waits until all of your application code has finished running before synchronizing changes.
Could this be why I am unable to retrieve the value of the bound property in the code? What exactly does "application code has finished running" entail?