mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-24 06:17:55 -05:00
clarified example; fixed typo
This commit is contained in:
20
index.html
20
index.html
@@ -1142,15 +1142,25 @@ var alphabetical = Books.sortBy(function(book) {
|
||||
</p>
|
||||
|
||||
<pre class="runnable">
|
||||
var ships = new Backbone.Collection;
|
||||
var Ship = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"name": "Black Pearl"
|
||||
}
|
||||
});
|
||||
|
||||
ships.bind("add", function(ship) {
|
||||
var Fleet = Backbone.Collection.extend({
|
||||
model: Ship
|
||||
});
|
||||
|
||||
var pirates = new Fleet();
|
||||
|
||||
pirates.bind("add", function(ship) {
|
||||
alert("Ahoy " + ship.get("name") + "!");
|
||||
});
|
||||
|
||||
ships.add([
|
||||
pirates.add([
|
||||
{name: "Flying Dutchman"},
|
||||
{name: "Black Pearl"}
|
||||
{captain: "Jack Sparrow"}
|
||||
]);
|
||||
</pre>
|
||||
|
||||
@@ -1585,7 +1595,7 @@ $(function(){
|
||||
<h2 id="Sync">Backbone.sync</h2>
|
||||
|
||||
<p>
|
||||
<b>Backbone.sync</b> is the function the Backbone calls every time it
|
||||
<b>Backbone.sync</b> is the function that Backbone calls every time it
|
||||
attempts to read or save a model to the server. By default, it uses
|
||||
<tt>(jQuery/Zepto).ajax</tt> to make a RESTful JSON request. You can override
|
||||
it in order to use a different persistence strategy, such as WebSockets,
|
||||
|
||||
Reference in New Issue
Block a user