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

router + template loader best practice

1 Answer 148 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Meir
Top achievements
Rank 1
Meir asked on 05 Feb 2014, 12:55 PM
Hi, I created an index.html page with router and template loader as described here:
http://docs.telerik.com/kendo-ui/howto/load-templates-external-files

Now what I'm trying to do is to dynamically load the template data each time I navigate to a new url.

The first part of clicking on links and navigating with using the router works perfect. It even has a great caching mechanism so it won't load each template more than once. The question is what is the best practice to inject the server data into the template?

For example let's say that I'm looking at a homepage and I have a link to the customers page. Click on the link will switch view to the customers.html and will show the template page. Now I need to load all the customers. When and how do I do that? In the template page? I think that it would be better if the code that loads the customers will be in a separate js file that will load the data, populate the viewModel (am I right here?) and bind it to the page. Same questions when clicking on a specific user in order to edit it in a new popup - when and what is the best way to load the data?

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 07 Feb 2014, 07:40 AM
Hello Meir,

In general, all server-side data retrieval in Kendo UI is performed through the DataSource component. You can perform  the data fetch/viewModel update in the respective URL route callback — this will automatically update the data-bound values in the template. You can check our Sushi sample application for a similar pattern.

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
SPA
Asked by
Meir
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or