Handle empty responses and errors for tag listings
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() {
{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();