New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on can.Model's nested object throws error on recursive mustache template #514

Closed
kustaahuhtala opened this Issue Oct 27, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@kustaahuhtala

Rendering recursive tree structure with can.Model and mustache works nicely, as you can see in this fiddle: http://jsfiddle.net/huhku/puYWE/5/

However, pushing newly created item into the tree structure (by clicking the button in the fiddle) throws an error in the console. The stack trace looks like an infinite loop of some sort (perhaps).

Strangely, this does not seem to be a problem with a simple can.Observable / can.Map (See this fiddle: http://jsfiddle.net/huhku/puYWE/3/ ), where everything seems to work as expected.

@kustaahuhtala

This comment has been minimized.

Show comment
Hide comment
@kustaahuhtala

kustaahuhtala Jan 27, 2014

With the latest canjs (2.0.4) the error message is actually "Uncaught RangeError: Maximum call stack size exceeded ".

With the latest canjs (2.0.4) the error message is actually "Uncaught RangeError: Maximum call stack size exceeded ".

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Apr 25, 2014

Contributor

This might be fixed by #883.

Contributor

justinbmeyer commented Apr 25, 2014

This might be fixed by #883.

@ccummings ccummings self-assigned this Apr 25, 2014

@ccummings ccummings added Bug labels Apr 25, 2014

@ccummings

This comment has been minimized.

Show comment
Hide comment
@ccummings

ccummings Apr 28, 2014

Contributor

This is fixed by #883. When 2.1 is released, you should change your template to:

<li {{data "item"}}>
    {{name}}
    <ul>
    {{#./children}} 
        {{>treeTemplate}}
    {{/./children}}
    </ul>
</li>

The ./ keeps the lookup of children to the current scope instead of trying to walk up to parent scopes looking for the children property (and never finding it).

Contributor

ccummings commented Apr 28, 2014

This is fixed by #883. When 2.1 is released, you should change your template to:

<li {{data "item"}}>
    {{name}}
    <ul>
    {{#./children}} 
        {{>treeTemplate}}
    {{/./children}}
    </ul>
</li>

The ./ keeps the lookup of children to the current scope instead of trying to walk up to parent scopes looking for the children property (and never finding it).

@ccummings ccummings closed this Apr 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment