mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Tweak url attachment a bit.
This commit is contained in:
13
index.html
13
index.html
@@ -1522,14 +1522,15 @@ var Library = Backbone.Collection.extend({
|
||||
may be included as an option. Passing <tt>false</tt> as the
|
||||
comparator option will prevent sorting. If you define an
|
||||
<b>initialize</b> function, it will be invoked when the collection is
|
||||
created. The constructor copies following fields from the options into
|
||||
instance variables: <tt>url</tt>, <tt>model</tt> and <tt>comparator</tt>.
|
||||
created. There are several options that, if provided, are attached to the
|
||||
collection directly: <tt>url</tt>, <tt>model</tt> and <tt>comparator</tt>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var tabs = new TabSet([tab1, tab2, tab3]);
|
||||
var spaces = new Backbone.Collection([], {
|
||||
url: "/spaces", model: Space
|
||||
model: Space,
|
||||
url: '/spaces'
|
||||
});
|
||||
</pre>
|
||||
|
||||
@@ -3842,13 +3843,17 @@ ActiveRecord::Base.include_root_in_json = false
|
||||
|
||||
<h2 id="changelog">Change Log</h2>
|
||||
|
||||
<b class="header">Edge</b> — <small><i>Unreleased</i></small><br/>
|
||||
<b class="header">Edge</b> — <small><i>Unreleased</i></small> — <a href="https://github.com/documentcloud/backbone/compare/0.9.10...master">Diff</a><br/>
|
||||
|
||||
<ul style="margin-top: 5px;">
|
||||
<li>
|
||||
The <tt>silent</tt> option has been removed from <tt>Model#set</tt>.
|
||||
Custom options should be used to accomplish this effect instead.
|
||||
</li>
|
||||
<li>
|
||||
Constructing a new collection with a <tt>url</tt> option will attach it
|
||||
to the new instance.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<b class="header">0.9.10</b> — <small><i>Jan. 15, 2013</i></small> — <a href="https://github.com/documentcloud/backbone/compare/0.9.9...0.9.10">Diff</a><br />
|
||||
|
||||
@@ -1049,18 +1049,20 @@ $(document).ready(function() {
|
||||
collection.add(collection.models, {merge: true}); // don't sort
|
||||
});
|
||||
|
||||
test("Copy known options into instance fields in the constructor", function() {
|
||||
var model = new Backbone.Model();
|
||||
var collection = new Backbone.Collection([], { model: model });
|
||||
equal(collection.model, model);
|
||||
test("Attach options to collection.", 3, function() {
|
||||
var url = '/somewhere';
|
||||
var model = new Backbone.Model;
|
||||
var comparator = function(){};
|
||||
|
||||
var url = "/somewhere";
|
||||
var collection = new Backbone.Collection([], { url: url });
|
||||
equal(collection.url, url);
|
||||
var collection = new Backbone.Collection([], {
|
||||
url: url,
|
||||
model: model,
|
||||
comparator: comparator
|
||||
});
|
||||
|
||||
var comparator = function() {};
|
||||
var collection = new Backbone.Collection([], { comparator: comparator });
|
||||
equal(collection.comparator, comparator);
|
||||
strictEqual(collection.url, url);
|
||||
ok(collection.model === model);
|
||||
ok(collection.comparator === comparator);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user