【发布时间】:2012-07-07 04:21:06
【问题描述】:
<a class="btn btn-primary" href="#" {{action "toggleStatus"}}><i class="icon-plus icon-white"></i> Add Staff</a>
这是在一个名为 stafflist.handlebars 的视图模板中。内容如下
<div class="page-header">
<h3>{{staff.title}} <small>List of users who has access to this application</small></h3>
</div>
<div class="commands pull-right">
sta
<a class="btn btn-primary" href="#" {{action "toggleStatus"}}><i class="icon-user icon-white"></i> {{staff.btnTitle}}</a>
</div>
<div class="pull-left">
<input type="text" class="search-query" placeholder="Search">
</div>
<table class="table table-striped table-bordered">
<thead>
<tr>
<td>NAME</td>
<td>ID</td>
</tr>
<thead>
<tbody>
{{#each staff}}
<tr>
<td>{{this.fname}}</td>
<td>{{this.id}}</td>
</tr>
{{/each}}
</tbody>
</table>
查看文件如下
App.StaffListView = Em.View.extend({
templateName:'sellap-web/~templates/stafflist',
staffBinding:'App.staffController',
toggleStatus: function() {
alert('Hurray');
}
});
单击按钮时,该操作永远不会调用警报。这里出了什么问题。我正在使用 ember-skeleton 进行编译。
【问题讨论】:
-
如果你的应用中有路由器,那么它就是助手的默认目标。你能提供一个jsfiddle吗?
-
代码使用RAKE打包编写。它将整个东西打包成一个 50,000 行的 app.js。我正在使用 ember-skeleton。
-
- 您是否在控制台中收到错误消息? - 您可以尝试将视图添加为动作助手中的目标。 {{action "toggleStatus" target="view"}}
-
找到了罪魁祸首。我的 App.create 有一个名为 init 的方法。我将名称更改为其他名称,现在它可以正常工作了。我没有打电话给超级。