This is a migrated thread and some comments may be shown as answers.

Addingattributes to LI when using templating

3 Answers 63 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Bart
Top achievements
Rank 1
Bart asked on 25 Jul 2013, 10:16 PM
http://docs.kendoui.com/api/mobile/listview#configuration-template

I am using templates, as described in the above link. In the docs is says, "The ListView automatically wraps the template content in <li> tag. Putting a <li> tag inside the template creates invalid nesting of elements."

So how do I add a class or another attribute to the LI item?

3 Answers, 1 is accepted

Sort by
0
Bart
Top achievements
Rank 1
answered on 25 Jul 2013, 10:32 PM
One way I just figured out is this, though there may be a better way to go about this?

onDataBound: function(event){
  event.sender.element.children().each(function(index, li) {
    $(li).addClass('status-warning');
  });
}
0
Kiril Nikolov
Telerik team
answered on 26 Jul 2013, 11:41 AM
Hi Bart,

I examined other options to achieve the effect you are looking for, but did not manage to find a better solution than the one that you already have. As the widget itself does not apply any styling to the <li> elements, there is no class attribute that can be used to style the elements, so you need to add one - as you do in your script binded to the DataBound event.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bart
Top achievements
Rank 1
answered on 26 Jul 2013, 01:37 PM
Thanks for looking into it, Kiril.
Tags
ListView (Mobile)
Asked by
Bart
Top achievements
Rank 1
Answers by
Bart
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or