Roney Banerjee
Roney Banerjee

Reputation: 333

Action Helper in Ember JS not calling function

<a class="btn btn-primary" href="#" {{action "toggleStatus"}}><i class="icon-plus icon-white"></i> Add Staff</a>

This is in a view template called stafflist.handlebars. The content is as follows

<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>

The View file is as below

App.StaffListView = Em.View.extend({
    templateName:'sellap-web/~templates/stafflist',
    staffBinding:'App.staffController',
    toggleStatus: function() {
        alert('Hurray');
    }
});

When clicking the button, the action is never calling the alert. What is going wrong here. I am using ember-skeleton to compile.

Upvotes: 0

Views: 832

Answers (1)

Roney Banerjee
Roney Banerjee

Reputation: 333

Found the culprit. My App.create has a method called init. I changed the name to something else and now it works fine. I didnt call the super.

Upvotes: 2

Related Questions