2015-02-07 74 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}}