From 39753e449376dff2824cb372427f843c20f98cc4 Mon Sep 17 00:00:00 2001 From: Jason Kneen Date: Wed, 28 Mar 2018 23:01:11 +0100 Subject: [PATCH] fix an issue where ignoring config.content wasn't respected --- reste.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/reste.js b/reste.js index 0673375..2ec72c2 100644 --- a/reste.js +++ b/reste.js @@ -485,7 +485,6 @@ var main = function() { methodCall(options, function(response) { if ((response != null) && (response != undefined)) { - if (options.success && response[collectionConfig.content]) { // check if we have a return property if (response[collectionConfig.content]) { @@ -494,25 +493,28 @@ var main = function() { item.id = item[modelConfig.id]; }); - options.success(response[collectionConfig.content]); + if (options.success) options.success(response[collectionConfig.content]); + Alloy.Collections[collectionConfig.name].trigger("sync"); + } else { + // otherwise just return an array with the response response.forEach(function(item) { item.id = item[modelConfig.id]; }); - options.success(response); + if (options.success) options.success(response); + Alloy.Collections[collectionConfig.name].trigger("sync"); } - } - } else { - option.success(response); } }, function(response) { + if (options.error) { options.error(response); } + }); } else if ( model instanceof Backbone.Model) {