This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.App = { | |
Models: {}, | |
Collections: {}, | |
Views: {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.App = { | |
Models: {}, | |
Collections: {}, | |
Views: {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require backbone_rails_demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Models.Album = Backbone.Models.extend() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.album = new App.Models.Album({ title: 'Bitches Brew'}); | |
// child {cid: "c2", attributes: Object, _changing: false, _previousAttributes: Object, changed: Object…} | |
App.album.get('title'); | |
// “Bitches Brew” | |
App.album.set({ title: 'Sketches of Spain' }); | |
// child {cid: "c2", attributes: Object, _changing: false, _previousAttributes: Object, changed: Object…} | |
App.album.get('title'); | |
// ”A New Title” |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/albums_controller.rb | |
def index | |
@albums = Album.where(user_id: params[:user_id]) | |
respond_with(@albums) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Collections.Albums = Backbone.Collection.extend | |
model: App.Models.Album | |
url: "/users/2/albums" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.albums = new App.Collections.Albums() | |
// child {length: 0, models: Array[0], _byId: Object, constructor: function, model: function…} | |
App.albums.fetch(); | |
// Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…} | |
App.albums.first() | |
// child {cid: "c1", attributes: Object, collection: child, _changing: false, _previousAttributes: Object…} | |
App.albums.first().get('title') | |
// “A Love Supreme" |