router + template loader best practice

2 posts, 0 answers
  1. Meir
    Meir avatar
    5 posts
    Member since:
    Jan 2014

    Posted 05 Feb 2014 Link to this post

    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?
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 07 Feb 2014 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top