I want to add some cards to a board, all the cards are very different so I make different views for each card I want to pack different events and templates. I set the 'Type' property in the card model that does the different to the card.
The board template looks like below:
{{every card in the card}} {{Render card.type card class = "card"}} {{/ }} However, the first argument for render help can not be a variable, it can only be the card view name string.
Anyone know how to achieve this?
As you've already mentioned the built in render assistant, A string accepts to look for a template to render, so a potential solution would be to write your own custom render assistant, then the card.get ('type' ) After obtaining the correct name with the the underlying the render assistant, rendering it something like this Can Ikhai is: Amber. Handlebers Registrar BoundHelper ('render card', function (reference, card, option) {return Ember.Handlebars.helpers.render.call (reference card .get ('type'), 'card', option);}); After that, you can use it in your template like this: {{# every card in the card}} {{this card Render}} edit
I have also added a basic that this works.
Editing 2
Using the object data to present in the template, JSBN was edited again.
Edit 3
Unfortunately DS.FixtureAdapter does not support embedded records which you need to do it. But you can configure orignal DS.RESTAdapter in this way: App.Adapter = DS.RESTAdapter.extend (); App.Adapter.map ('app. Dashboard', card: {embedded: 'always'}); App.Store = DS.Store.extend ({adapter: App.Adapter}); The card record always is filled with the parent record. I think in order to call this change, in the card.get ('type') you will send the value to the handlebar of the handlebar again undefined . Hope it helps.
No comments:
Post a Comment