Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HotTowel/Durandal view compose limitations

I'm trying to implement SPA with HotTowel Template by John Papa. Is there a limitation on how many levels of ko compose I can do?

In the shell.html it calls

<!-- ko compose: { model: router.activeItem .... } --><!-- /ko -->

Within my active view, I try to embed another view, and then I tried to embed another view and so on.

In home.html.

<!-- ko compose: { model: $data, view: view1 } --><!-- /ko -->

In view1.html, I do

<!-- ko compose: { model: $data, view: view2 } --><!-- /ko -->

In view2.html, I do

<!-- ko compose: { model: $data, view: view3 } --><!-- /ko -->

Problem is View3 is not called.

I confirmed this in the Chrome debugger trace, view3 is never called. Is there a limitation in how many levels I can go? If so how can I get around this?

Thanks in advance.

Cheers

Michael

like image 721
Michael Pang Avatar asked Nov 20 '25 04:11

Michael Pang


1 Answers

As you've now found out -you have to have a root element in your view (it explicitly states this in the Durandal docs):

The view has exactly one root element. Durandal requires this. If comments are found at the root, they will be removed. In the case where more than one root element is found, they will be wrapped in a div.

like image 164
gerrod Avatar answered Nov 22 '25 22:11

gerrod