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

How to render a complete <div>?

4 Answers 158 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 03 Sep 2013, 09:26 AM
 I've following <div>-element:
  <div id="data"></div>
and creating dynamically via Javascript function following HTML code and insterting it into the <div>-element
html += "  <ul data-role=\"listview\" data-style=\"inset\" data-type=\"group\">";
 html +=
"   <li>";
 html +=
"    <ul>";
 html +=
"     <li data-icon=\"play\"><a href=\"../play-music.html\">Play Music</a></li>";
 html +=
"     <li data-icon=\"cart\"><a href=\"../music-store.html\">Buy Music</a></li>";
 html +=
"    </ul>";
 html +=
"   </li>";
 html +=
"  </ul> ";

 document.getElementById(
"data").innerHTML = html;
The output wasn't rendered. How could I render it? Every function I've tried of the framework did't redner the complete <div> only parts :(

4 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 04 Sep 2013, 07:01 AM
Hello Christian,

The ListView is not rendered properly because it needs to be inside a View. You can use the div as a view by adding a data-role="view" attribute to it, as shown in this example.
 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Christian
Top achievements
Rank 1
answered on 04 Sep 2013, 09:47 AM
First thank you for the fast response.

Yes, it's true if I append the code on starting the page before the application is instantiated. But is there any possibility to do it after, maybe after a button click.

Here I made an example, when the code will appended on the init event of the application. I've tried different methods to re-render, but without any solution.
Example

If I use Kendo UI Templates only with the content of the <li>-tags it works, but only with a flat structure to like
<a href="${url}" data-icon="${icon}">${text}</a>

This doesn't work, because it doesn't render the <div> with the icon:
<a href="${url}"><div data-icon="${icon}"></div>${text}</a>
So, isn't it possible to re-render complex structures?

Regards,

Christian
0
Accepted
Alexander Popov
Telerik team
answered on 05 Sep 2013, 02:20 PM
Hi again Christian,

You can re-render the View by using the kendo.init method and passing the kendo.mobile.ui namespace, as shown in this example.
Additional information on Data attribute initialization can be found here.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Christian
Top achievements
Rank 1
answered on 05 Sep 2013, 02:46 PM
Perfect, works fine. Thank you very much.
Tags
General Discussions
Asked by
Christian
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Christian
Top achievements
Rank 1
Share this question
or