Page 2 of 4

Add or Remove ListItem from List Manually

Posted: Mon Apr 06, 2015 7:31 pm
by Egor Kotov6832188

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.


Add or Remove ListItem from List Manually

Posted: Mon Apr 06, 2015 7:54 pm
by xman

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?


Add or Remove ListItem from List Manually

Posted: Tue Apr 07, 2015 9:57 pm
by xman

ping? ..anyone?


Add or Remove ListItem from List Manually

Posted: Tue Apr 07, 2015 9:57 pm
by xman

ping? ..anyone?


Add or Remove ListItem from List Manually

Posted: Tue Apr 07, 2015 11:46 pm
by Yurii Orishchuk

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.


Add or Remove ListItem from List Manually

Posted: Wed Apr 08, 2015 4:14 am
by xman

...this did not work for me :(


Add or Remove ListItem from List Manually

Posted: Wed Apr 08, 2015 11:24 am
by xman

Hi Yurii,

That solution above did not work, any ideas?


Add or Remove ListItem from List Manually

Posted: Wed Apr 08, 2015 1:57 pm
by xman

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


Add or Remove ListItem from List Manually

Posted: Wed Apr 08, 2015 2:26 pm
by Illya Stepanov

Hi -

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


Add or Remove ListItem from List Manually

Posted: Wed Apr 08, 2015 3:12 pm
by xman

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