xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Add or Remove ListItem from List Manually

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.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Add or Remove ListItem from List Manually

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

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Add or Remove ListItem from List Manually

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?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Add or Remove ListItem from List Manually

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.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Add or Remove ListItem from List Manually

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

Joel Swota
Posts: 0
Joined: Thu Feb 04, 2016 8:22 pm

Add or Remove ListItem from List Manually

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Add or Remove ListItem from List Manually

Hello Joel,

Could you clarify, what are you trying to do?

Joel Swota
Posts: 0
Joined: Thu Feb 04, 2016 8:22 pm

Add or Remove ListItem from List Manually

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Add or Remove ListItem from List Manually

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

Return to “Issues”