0

I used a template in my application like:

<section class="view-list" data-bind="template: { name: viewTemplate, foreach: locaFacts }">

but in some cases, mostly on the first load the output html is lots of Loading... instead of real templates.

It seems that knockout shows Loading... until the view model gets ready. As I cached the results, the second call will show the templates correctly.

Why the first call to template shows Loading... instead of template itself?

EDIT:

I use knockout external templates and infuser.

mehrandvd
  • 8,806
  • 12
  • 64
  • 111
  • There no functionality built in to Knockout which would show these "Loading..." messages. So it is shown by your own code or you are using some other plugin which does this.... – nemesv Jun 29 '13 at 06:12
  • @nemesv Yep, I used ko external template and infuser – mehrandvd Jul 08 '13 at 11:46

2 Answers2

3

I was able to correct this by setting ajax option async to false by modifying the template binding like so:

<div class="pagination" data-bind="template: { name: 'pager', data: pager, ajax: { async: false } }">
  • It seems a good solution. Thanks for letting me know about this feature. But I'm not able to test it now as I migrated to Durandal! – mehrandvd Aug 21 '13 at 06:31
0

I changed my template engine and used Durandal's compose feature. Now everything is OK.

mehrandvd
  • 8,806
  • 12
  • 64
  • 111