Ember.js is a framework for creating ambitious web applications.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App = Ember.Application.create();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.ApplicationController = Ember.Controller.extend();
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/'
})
})
});
And Handlebars template
<script type="text/x-handlebars" data-template-name="application">
Hello RW!
</script>
{{! Don't do it! }}
<div {{#if isUrgent}}class="urgent"{{/if}}>
{{unbound color}}
// of better
{{bindAttr src="url"}}
Backbone.js
var AppView = Backbone.View.extend({
tagName : "div"
, template : "app"
, render : function() {
// your code to render here.
}
, events : {
"click .linkme" : "mark_as_done"
, "change .body" : "update_body"
}
, mark_as_done : function() { /* code here */ }
, update_body : function() { /* code here */ }
});
Ember.js
var AppView = Ember.View.extend({
templateName : "app"
, mark_as_done : function() { /* code here */ }
, update_body : function() { /* code here */ }
});
Search templates be script DOM id or in "Ember.TEMPLATES" array.
Backbone.js
var Group = Backbone.Model.extend();
Ember.js
var Group = Ember.Object.extend();
also exist "Ember.Data"
var Group = DS.Model.extend({
name: DS.attr('string'),
url: DS.attr('string'),
isActive: DS.attr('boolean')
});
Backbone.js
Ember.js
Differences
You can block this:
window.Ember = {};
Ember.EXTEND_PROTOTYPES = false;
In this case you will need to manually extend or create the objects
Ember.A(array); // arrays
Ember.String(string); // string
Contact information