Вопрос

The title pretty much says it.

If I am using a kendo ui template for a listview:

<script type="text/x-kendo-template" id="myTemplate">
...
</script>

is it possible to apply styling to the parent node that will wrap around my template, using javascript WITHIN the template? In this case I wish to target the background-color of the li tag that will wrap around my template.

I'm not sure how to start, as I don't even know if it's possible to get a reference to the current element.. I've tried the keyword this but it didn't work:

# this.className = "myclass"; #

As an update:

Each listview item that's created from the template is given a uid, I am investigating if it's possible to capture that specific uid and add a class to the element that way..

Это было полезно?

Решение

You can try multiple solutions: 1 create a span or a to wrap your contents inside the template and assign background color to it styles to it.

<script type="text/x-kendo-template" id="myTemplate">
<div class="#: myclass#"> 
<!-- tempalte contents-->

</div>
</script>
  1. Wrap the list in a div and then using the div id, assign class to the list inside the div once the list is generated using jQuery. You can use the dataBound event of the list view to process the
  2. s generated.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top