Created
August 25, 2017 23:07
-
-
Save raybelisle/ad026ce18ebe13f4041de7e57070efcf to your computer and use it in GitHub Desktop.
Alloy ListView Template with changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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