generator-thorax
generator-thorax copied to clipboard
Rendering child views fails
I have not found a way of passing a view to a template and rendering it using the {{view childViewName}} helper. In fact I'm quite sure that somehow helpers are broken for me (?) as I get the same error whenever I try to use other kinds of helpers (e.g. {{collection someCollection}})
The error: Uncaught TypeError: Cannot read property '_helperName' of undefined StackOverflow to reproduce
Just curious. Why aren't you using the template thorax provides? Like this... In your router... index: function () { var view = new ParentView({ child: new BunnyRabbitsListView(), }); RootView.getInstance().setView(view); }
Then in your BunnyRabbitsListView template you can place
Hello World
.in the index template {{view child}} will render.
Same for child collections. On your route you can do something like this...
index: function () { var bunnies = new BunnyRabbitsListView(), var view = new ParentView({ child: new BunnyRabbitsListView({ bunnylist: bunnies }); }); RootView.getInstance().setView(view); }
Then in your BunnyRabbitsListView template...
{{#collection bunnylist}} {{your bunny model attrs}} {{/collection}}
With the version that is referenced in this generator, this bug has not been fixed like it has been in the Thorax library. Please see https://github.com/walmartlabs/generator-thorax/pull/149 for some more info. You can do this in Thorax proper (especially in IE11) but the fix has not been pulled downstream to this project @ChadMartinson