2015-02-07 80 views
0

嘿,请任何人都可以帮助我解决这个问题。 我的看法是谷歌图表在Ember.js中渲染

<div id="sankey_multiple" style="width: 900px; height: 300px;"></div> 

我Component.js是

App.sankeyComponent = Ember.Component.extend({ 
    needs: ['sankey'], 
    //navigation: Ember.computed.alias('controllers.navigation'), 
    isExpandedBookmarks: false, 
    didInsertElement: function() { 
     alert('insert'); 
    } 
}); 

但didInsertElement功能无法正常工作,我没有得到确切位置在哪里我需要添加谷歌图表脚本。

如果我在init函数中添加它,它说容器找不到。所以我认为我们需要在didInsertElement之后添加。但它不工作。任何人都可以帮我解决这个问题吗?先谢谢你。

回答

0

灰烬预计,组件有一个领先的资本的命名规则,所以你应该如下更改组件:

App.SankeyComponent = Ember.Component.extend({ 
    needs: ['sankey'], 
    //navigation: Ember.computed.alias('controllers.navigation'), 
    isExpandedBookmarks: false, 
    didInsertElement: function() { 
     alert('insert'); 
    } 
}); 

而且,我不知道您发布的视图是否是你所在的视图试图消耗你的组件或组件本身的视图。这些应被设置为可能的:

定义为组件:

<script type="text/x-handlebars" id="components/sankey-component "> 
    <!-- HTML for your component --> 
</script> 

显示在一个视图中的组件,如下所示:

{{sankey-component}}