Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render Ember component dynamically

Rendering a component works well when using {{component-name}} in template. I want to render a component from route with dynamic parameters. I've tried this

App.ApplicationRoute = Ember.Route.extend({
  init: function(){
      this.render("components/comp-two", {
        into: "application",
        outlet: "test"
      });

  }
});

It successfully renders a template, but component's events(init, didInsertElement) and actions don't work.

How to make events and actions work ?

example: http://emberjs.jsbin.com/badaku/1/

like image 339
Tomas Avatar asked Oct 19 '22 15:10

Tomas


1 Answers

If you give some template name in render method, ember only will render that specific template, it will not be considered as a component.You can create a dummy template, inside that you can use your component.

I have updated your jsBin example http://jsbin.com/pajirefeta/1/edit

like image 179
Vaibhav Avatar answered Nov 01 '22 13:11

Vaibhav