Page 4 of 4

Add or Remove ListItem from List Manually

Posted: Sat Apr 18, 2015 2:01 pm
by xman

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.


Add or Remove ListItem from List Manually

Posted: Sun Apr 19, 2015 4:01 am
by xman

...anyone? Can you help me with the issue in last comment above


Add or Remove ListItem from List Manually

Posted: Sun Apr 19, 2015 4:41 pm
by xman

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?


Add or Remove ListItem from List Manually

Posted: Mon Apr 20, 2015 2:19 am
by Yurii Orishchuk

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.


Add or Remove ListItem from List Manually

Posted: Tue Apr 21, 2015 3:53 am
by xman

great that solves my problem, I had tried a solution but it was not perfect!


Add or Remove ListItem from List Manually

Posted: Mon Feb 08, 2016 5:16 pm
by Joel Swota

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


Add or Remove ListItem from List Manually

Posted: Mon Feb 08, 2016 9:27 pm
by Serhii Kulibaba

Hello Joel,

Could you clarify, what are you trying to do?


Add or Remove ListItem from List Manually

Posted: Mon Feb 08, 2016 9:31 pm
by Joel Swota

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.


Add or Remove ListItem from List Manually

Posted: Wed Feb 10, 2016 7:42 pm
by Serhii Kulibaba

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