mercredi 13 janvier 2016

Adding component dynamically in Ember

using Ember : 1.13.11, Ember Data : 1.13.8, ember-cli : 1.13.12

I want to add a component dynamically to webpage - this webpage is template of another component don't think that it will make any difference-. Here is my code snippet in which I try to add a component named LyricsEditorLine to <div> tag, somehow like this

agenda-alpha/components/lyrics-editor.js

import Ember from 'ember';
import LyricsEditorLine  from 'agenda-alpha/components/lyrics-editor-line';

export default Ember.Component.extend({
   afterRenderEvent:function(){
      LyricsEditorLine.create().appendTo($("#in"));
 },
init:function(){
  Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
  this._super();
 }
});

agenda-alpha/templates/components/lyrics-editor.hbs

<div id='in'> </div>

every time this gives me

 'Uncaught Error: Assertion Failed: You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead'

Looked for ContainerViewhere found that it is deprecated Most of the answers that I found are not using ember-cli and being a beginner makes it harder to understand




Aucun commentaire:

Enregistrer un commentaire