Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Add or Remove ListItem from List Manually

Hello,

Here is an example
http://gyazo.com/1f400a4586de3aa7b72b...
You can see list items from list component on screenshot above.
If you look closer at last item you would see, that it has next:
data-aperry-tpl="true"
property, which means that it is used by Appery.io during mapping to create new item.

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

Add or Remove ListItem from List Manually

The problem is I need help with JS to achieve this. Can you help with JS? What JS do I write to find the listitem element and then add new list item?

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

Add or Remove ListItem from List Manually

ping? ..anyone?

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

Add or Remove ListItem from List Manually

ping? ..anyone?

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 insert new list item to certain list component.

precode

var newItemText = "Hello this is new item&quot

//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);

/code/pre

Regards.

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

Add or Remove ListItem from List Manually

...this did not work for me :(

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

Add or Remove ListItem from List Manually

Hi Yurii,

That solution above did not work, any ideas?

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

Add or Remove ListItem from List Manually

Did this not work because I have a label placed inside the list?
http://gyazo.com/6cffdd55eb0ce1a4e956...

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Add or Remove ListItem from List Manually

Hi -

Yurii showed you a basis example, you will need to modify it for your implementation.

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

Add or Remove ListItem from List Manually

That is right, and I did modify it and change names etc. But did not work, that is confusing me.

Return to “Issues”