简体   繁体   English

在Ember.js中向动态内容添加动作帮助程序的问题

[英]Issue adding action helper in Ember.js to dynamic content

I want to use an action helper on content that is being dynamically generated. 我想对动态生成的内容使用动作帮助器。 I'm pulling data in and creating rows of records. 我正在拉入数据并创建记录行。 Each record has an edit and delete button being added to it. 每个记录都有一个添加到其中的编辑和删除按钮。 The purpose is to monitor an event and pass it to the router. 目的是监视事件并将其传递给路由器。 In another instance I have an event -> disableScroll being monitored when a user goes to enter a new record. 在另一个实例中,我有一个事件-> disableScroll,当用户进入新记录时会受到监视。 This successfully executes as it's wrapped within: 它成功执行,因为它包含在其中:

<script type="text/x-handlebars" data-template-name="form">
    <a href="#new-record" {{action "disableScroll" on="click"}}>New Record</a>    

     ....
     ....
     ....
</script>

I want to replicate this with n number of edit buttons. 我想用n个编辑按钮来复制它。 The edit button is being appended to the data brought in by the model and pushed as a new field in the record. 编辑按钮将附加到模型引入的数据中,并作为记录中的新字段推送。

row.push("<a href='#edit-record' id='"+variable+"'>Edit Record</a>"); 

我通过在用户单击视图中的按钮时向路由器发送事件来解决问题,而不是尝试在模板中附加动作帮助器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM