commit:0085ebfed447d3e7a828eb691a78c5ccc2c21a8c
author:Chip Black
committer:Chip Black
date:Sun Nov 17 15:25:09 2013 -0800
parents:1a21466c7e3f8c18c4c35df56c270546ae8e6434
Handle empty responses and errors for tag listings
diff --git a/www/jssrc/blerg/API.js b/www/jssrc/blerg/API.js
line changes: +10/-2
index 908c213..986ac09
--- a/www/jssrc/blerg/API.js
+++ b/www/jssrc/blerg/API.js
@@ -163,14 +163,22 @@ enyo.kind({
         var req = new enyo.Ajax({
             url: url
         });
-        req.response(function(inSender, inResponse) {
+        req.response(this, function(inSender, inResponse) {
             this.bubble('onItemsLoaded', {
                 type: 'tag',
                 tagType: type,
                 tag: tag,
                 entries: inResponse
             });
-        }.bind(this));
+        });
+        req.error(this, function() {
+            this.bubble('onItemsLoaded', {
+                type: 'tag',
+                tagType: type,
+                tag: tag,
+                entries: []
+            });
+        });
         req.go();
     },
     getFeedInfo: function() {

diff --git a/www/jssrc/blerg/Pager.js b/www/jssrc/blerg/Pager.js
line changes: +9/-5
index 92f6f4c..f311d1f
--- a/www/jssrc/blerg/Pager.js
+++ b/www/jssrc/blerg/Pager.js
@@ -8,11 +8,15 @@ enyo.kind({
         {name: "spinner", kind: "OldSchoolSpinner", showing: false}
     ],
     addItems: function(items) {
-        this.$.records.createComponents(items, {kind: this.listKind});
-        for (var i = 0; i < items.length; i++) {
-            var r = parseInt(items[i].record);
-            if (r < this.lastRecord || this.lastRecord == null)
-                this.lastRecord = r;
+        if (items.length > 0) {
+            this.$.records.createComponents(items, {kind: this.listKind});
+            for (var i = 0; i < items.length; i++) {
+                var r = parseInt(items[i].record);
+                if (r < this.lastRecord || this.lastRecord == null)
+                    this.lastRecord = r;
+            }
+        } else {
+            this.$.records.createComponent({content: "No items"});
         }
         this.$.records.render();
         this.stopLoadAnimation();