I used the following which clears the list but then the above solution does not work at all:
list.empty().listview("refresh");
I'm guessing this also removed everything and the data-appery-tpl property. So the search above fails to do anything.
I used the following which clears the list but then the above solution does not work at all:
list.empty().listview("refresh");
I'm guessing this also removed everything and the data-appery-tpl property. So the search above fails to do anything.
...anyone? Can you help me with the issue in last comment above
I am stuck; can anyone help me how I can clear the list on button click and also not loose the data-appery-tpl="true" property that I added?
Hi xman,
Here is a code to remove all list items from the list:
pre
//Where "mobilelist_97" is your list component name.
var list = Apperyio("mobilelist_97");
//Get all list items.
var listItems = list.find('li:not([data-appery-tpl="true"])');
//Remove all list items.
listItems.remove();
/pre
Regards.
great that solves my problem, I had tried a solution but it was not perfect!
Hi,
I am trying something similar and used your suggestion as follows...
var newItemText = "Hello this is new item";
//Where "mobilelist_47" is your list component name.
var list = Apperyio("mobilelist_47");
//Get list template item.
var templateITem = list.find('li[data-appery-tpl="true"]');
var newItem = templateITem.clone().removeAttr("data-appery-tpl");
//Set text to new item
newItem.find("h3").text(newItemText);
//Append new item to end of the list component.
newItem.insertBefore(templateITem);
This code is working fine for me but the new items are not showing up. I use alert to show me the number of listitems and they increase accordingly as i add new items. Am i missing some visible property or something?
Thanks,
Joel
Hello Joel,
Could you clarify, what are you trying to do?
I am trying to manually add ListItems to a List control. I can see the list's item count increasing but the populated control won't show up on my form.
We are very sorry, but if you are using custom JS functions - it is something outside the scope (http://devcenter.appery.io/support-po...) of our standard support. Please use mappings for that