From f75d94c31391e62886ce4c4ca8e245c1ec40ea92 Mon Sep 17 00:00:00 2001 From: "Evgheni C." Date: Mon, 6 Oct 2014 23:04:03 +0300 Subject: [PATCH 1/2] Apply custom opts, related to a specific field Make possible to pass custom options per a specific field. Usage example - document.fetch({ byField: { 'data_character_info': { silent: true } } }) --- backbone-nested.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backbone-nested.js b/backbone-nested.js index 0bd6a46..51b51c1 100644 --- a/backbone-nested.js +++ b/backbone-nested.js @@ -69,6 +69,11 @@ var attrs = key; for (var _attrStr in attrs) { if (attrs.hasOwnProperty(_attrStr)) { ++ // Apply custom opts, related to a specific field ++ if (opts.byField && opts.byField[_attrStr]) { ++ opts = _.extend(opts, opts.byField[_attrStr]); ++ } + this._setAttr(newAttrs, Backbone.NestedModel.attrPath(_attrStr), opts.unset ? void 0 : attrs[_attrStr], From 9e0df0a363fec44822fc6fc79fa14c7b16b1701a Mon Sep 17 00:00:00 2001 From: "Evgheni C." Date: Tue, 7 Oct 2014 12:18:40 +0300 Subject: [PATCH 2/2] Misstype fixes --- backbone-nested.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backbone-nested.js b/backbone-nested.js index 51b51c1..a570ab3 100644 --- a/backbone-nested.js +++ b/backbone-nested.js @@ -69,10 +69,10 @@ var attrs = key; for (var _attrStr in attrs) { if (attrs.hasOwnProperty(_attrStr)) { -+ // Apply custom opts, related to a specific field -+ if (opts.byField && opts.byField[_attrStr]) { -+ opts = _.extend(opts, opts.byField[_attrStr]); -+ } + // Apply custom opts, related to a specific field + if (opts.byField && opts.byField[_attrStr]) { + opts = _.extend(opts, opts.byField[_attrStr]); + } this._setAttr(newAttrs, Backbone.NestedModel.attrPath(_attrStr),