generator-thorax icon indicating copy to clipboard operation
generator-thorax copied to clipboard

Rendering child views fails

Open Zensavona opened this issue 11 years ago • 3 comments

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

Zensavona avatar Apr 16 '14 03:04 Zensavona

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.

ChadMartinson avatar May 08 '14 21:05 ChadMartinson

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}}

ChadMartinson avatar May 08 '14 21:05 ChadMartinson

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

qbunt avatar Jul 13 '15 21:07 qbunt