- API docs
- How to bootstrap a project
- Application structure (M/V/C layers and what they're for)
- Getting started with Ember and Rails
- Built-in controls
- How events are handled and bubbled
App.messageController = Ember.Object.create | |
message: "Hello, world!" | |
# Compiles to: | |
# App.messageController = Ember.Object.create({ | |
# message: "Hello, world!" | |
# }); | |
# Okay, let's refactor it and delete the message property: |
The rules for how Ember.js evaluates Handlebars templates have recently changed, and you may need to update your application's templates to ensure they continue working..
Remember that a template is always evaluated against a context object. When you render a template, values are looked up from that object. For example:
Hello, {{firstName}} {{lastName}}!
WARNING
This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!
An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars
.
<header>
Many existing JSON APIs are not consistent between types. As JSON endpoints grew organically and were built by different engineers at different times, the style in which records are represented can vary wildly.
Historically, we have asked adapter authors to rely on the fact that the type of record is
provided to all adapter hooks (either by passing a type
argument, or by passing a record
An important feature for Ember Data is providing helpful error messages when your application tries to do something that is forbidden by the data model.
To that end, we would like for the data model to be able to mark certain records, attributes, and relationships as read-only. This ensures that we can provide errors immediately, and not have to wait for a return trip from the adapter.
This also means that the adapter does not need to handle the case where an application developer inadvertently makes changes to a record that it does not conceptually make sense to modify on the client.
//our app | |
var HelloEmber = Ember.Application.create({}); | |
//our model | |
HelloEmber.Greeting = Ember.Object.extend(); | |
HelloEmber.Greeting.reopenClass({ | |
get : function(){ | |
return {greeting : "Good Morning Starshine!", happyThought : "The Earth Says Hello!"} | |
} | |
}); |
Internally, Ember Data models use a state machine to represent their lifecycle. One of the limitations of the current implementation is that records cannot be modified:
- By the client application if the record is in-flight, or
- By the server (via an out-of-band
load()
) if the record has pending changes on the client.
App.Adapter = DS.Adapter.extend({ | |
/* | |
Called when the store needs the data payload for a particular record. It | |
gets the type and ID and should return a promise that resolves to a JSON | |
payload that contains the record. | |
For example, this might be called like this: | |
findRecord(App.Person, "1") |