Skip to content

Instantly share code, notes, and snippets.

@raybelisle
Created August 25, 2017 23:07
Show Gist options
  • Save raybelisle/ad026ce18ebe13f4041de7e57070efcf to your computer and use it in GitHub Desktop.
Save raybelisle/ad026ce18ebe13f4041de7e57070efcf to your computer and use it in GitHub Desktop.
Alloy ListView Template with changes
function updateListView(records) {
if (records === 0) {
var item = $.postsList.sections[0].getItemAt(0);
item.template = 'noDataTemplate';
$.postsList.sections[0].updateItemAt(0, item);
} else {
var item = $.postsList.sections[0].getItemAt(0);
item.template = 'zero';
$.postsList.sections[0].updateItemAt(0, item);
}
}
Alloy.Collections.posts.fetch({
success : function(col) {
updateListView(col.models.length);
}
});
Alloy.Collections.posts.on("remove add", function(e) {
updateListView(Alloy.Collections.posts.length);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment