2014-09-11 29 views
4

我在我的机智的一端试图完成什么应该是非常简单的行为:我有一个Ember表格组件(从Addepar),我想在该表中的按钮,触发一个模态对话框。打开模式对话框从内部表格单元

由于我是新来的灰烬,我开始与现有的灰烬表入门套件jsbin这里:http://jsbin.com/fasudiki/9/edit

我添加了一个自定义单元格视图,所以我可以用我自己的模板:

columns: function() { 
    var firstColumn; 
    firstColumn = Ember.Table.ColumnDefinition.create({ 
     columnWidth: 350, 
     textAlign: 'text-align-right', 
     headerCellName: 'Column 1', 
     tableCellViewClass: 'App.EmberTableMyCustomCell', 
     getCellContent: function(row) { 
     return row.get('myRandomValue').toFixed(2); 
     } 
    }); 

    return [firstColumn]; 
    }.property(), 

App.EmberTableMyCustomCell = Ember.Table.TableCell.extend({ 
    templateName: 'custom-table-cell', 
    classNames: 'custom-table-cell' 
}); 

<script type="text/x-handlebars" data-template-name="custom-table-cell"> 
    <span class="ember-table-content"> 
    {{ view.cellContent}} 
    <button {{action 'openModal' 'modal'}}>This one doesn't</button> 
    <button {{action 'myCellAction' 'modal'}}>This one doesn't either</button> 
    </span> 
</script> 

我又试图按照官方灰烬指南模态对话框:http://emberjs.com/guides/cookbook/user_interface_and_interaction/using_modal_dialogs/

在灰烬的术语,我希望能够从余烬表组件内的触发指标航线上的动作。

我试图直接从没有工作模板触发动作:

<button {{action 'openModal' 'modal'}} >Open modal</button> 

我又试图什么建议在“发送操作从元器件到你的应用程序”指南: http://emberjs.com/guides/components/sending-actions-from-components-to-your-application/

通过创建一个“动作”地图上的App.EmberTableMyCustomCell视图,然后用这两种

this.send('openModal', 'modal'); 

this.sendAction('openModal', 'modal'); 

再次,没有成功。

我又试图什么在这太问题建议: Ember component sendAction() not working

在我烬表的自定义属性设置操作名称,并用它在使用triggerAction参数(...):

<div class="table-container"> 
    {{table-component 
    hasFooter=false 
    columnsBinding="columns" 
    contentBinding="content" 
    myCustomActionName="openModal" 
    }} 
</div> 

actions : { 
    myCellAction : function() { 
     this.triggerAction('myCustomActionName', 'modal'); 
    } 
    } 

同样,没有成功。

任何想法我做错了什么?

我已经把代码jsbin:http://jsbin.com/yovikaviseve/2/edit

回答

0

我相信,(可惜)你在App.EmberTableMyCustomCell动作不会被调用。我不确定这是否是最佳解决方案,但我能够通过扩展Ember.Table.EmberTableComponent并在那里定义我的操作来解决该问题。一旦行动在那里被调用,我就能够使用链接的SO帖子中的方法将行动传播到ApplicationController

我实际发送的主要动作,而不是让事情简单一点,如下所述:http://emberjs.com/guides/components/sending-actions-from-components-to-your-application/

这里的工作示例:http://emberjs.jsbin.com/yemebu/3/edit

感谢包括JS斌 - 使人们更容易让我看看。如果您有更多问题或者这种方法对您无效,请告诉我!

相关问题