How to load partials / views / templates dynamically in Ember.js

后端 未结 4 1511
耶瑟儿~
耶瑟儿~ 2021-02-04 14:14

So I have the following setup.

On the main page, a list of generators is being displayed based on a list coming from a model using fixture data.

Now when one of

4条回答
  •  逝去的感伤
    2021-02-04 15:09

    While @Darshan's answer is simpler than the below and will work in many cases, I just ran into an issue where transitioning to a same route with a different model causes the partial to not re-render if the second model's partial name is the same as the first's (bug in ember?). Setting up a view that watches the model fixes this.

    App.FooDynamicLayout = Ember.View.extend
      rerenderOnModelChange: (->
        @rerender()
      ).observes('model')
    

    And call it with:

    view App.FooDynamicLayout templateName=dynamicTemplateName model=model
    

提交回复
热议问题