|
791 | 791 | // collection immediately, unless `wait: true` is passed, in which case we
|
792 | 792 | // wait for the server to agree.
|
793 | 793 | create: function(model, options) {
|
794 |
| - var coll = this; |
| 794 | + var collection = this; |
795 | 795 | options = options ? _.clone(options) : {};
|
796 | 796 | model = this._prepareModel(model, options);
|
797 | 797 | if (!model) return false;
|
798 |
| - if (!options.wait) coll.add(model, options); |
| 798 | + if (!options.wait) collection.add(model, options); |
799 | 799 | var success = options.success;
|
800 | 800 | options.success = function(model, resp, options) {
|
801 |
| - if (options.wait) coll.add(model, options); |
| 801 | + if (options.wait) collection.add(model, options); |
802 | 802 | if (success) success(model, resp, options);
|
803 | 803 | };
|
804 | 804 | model.save(null, options);
|
|
1314 | 1314 |
|
1315 | 1315 | });
|
1316 | 1316 |
|
1317 |
| - // The self-propagating extend function that Backbone classes use. |
1318 |
| - var extend = function(protoProps, classProps) { |
1319 |
| - return inherits(this, protoProps, classProps); |
1320 |
| - }; |
1321 |
| - |
1322 |
| - // Set up inheritance for the model, collection, and view. |
1323 |
| - Model.extend = Collection.extend = Router.extend = View.extend = extend; |
1324 |
| - |
1325 | 1317 | // Backbone.sync
|
1326 | 1318 | // -------------
|
1327 | 1319 |
|
|
1421 | 1413 | // Helper function to correctly set up the prototype chain, for subclasses.
|
1422 | 1414 | // Similar to `goog.inherits`, but uses a hash of prototype properties and
|
1423 | 1415 | // class properties to be extended.
|
1424 |
| - var inherits = function(parent, protoProps, staticProps) { |
| 1416 | + var extend = function(protoProps, staticProps) { |
| 1417 | + var parent = this; |
1425 | 1418 | var child;
|
1426 | 1419 |
|
1427 | 1420 | // The constructor function for the new subclass is either defined by you
|
|
1457 | 1450 | return child;
|
1458 | 1451 | };
|
1459 | 1452 |
|
| 1453 | + // Set up inheritance for the model, collection, and view. |
| 1454 | + Model.extend = Collection.extend = Router.extend = View.extend = extend; |
| 1455 | + |
1460 | 1456 | // Helper function to get a value from a Backbone object as a property
|
1461 | 1457 | // or as a function.
|
1462 | 1458 | var getValue = function(object, prop) {
|
|
0 commit comments