emberjs: when I try to use the action helper, i get - Handlebars error: Could not find property 'action' on object

Go To StackoverFlow.com

0

I have been trying to use the action helper with ember. I get the following error: Handlebars error: Could not find property 'action' on object .

I think I am following the examples in my simplified view here:

<script type="text/x-handlebars" data-template-name="user-edit">
    <p><a href="#" {{action "showUsersList"}}>Back</a></p>
</script>

The view object:

App.UserEditView = Ember.View.extend({
    templateName: 'user-edit',
    userBinding: 'App.usersController.selectedUser',
    tagName: 'span',
    didInsertElement: function () {
        $('h1').html('Edit User');
        document.title = 'Edit User';
    },
    showUsersList: function(event) {
        App.usersController.showUsersList();
    }
});

Any idea why I cannot use the action helper like in the examples?

Thanks, Robert

2012-04-03 23:06
by Robert Beaupre


2

You can also simply create the view and append it to the document. You don't need the second handlebars template.

App.UserEditView = Ember.View.create({
    templateName: 'user-edit',
    userBinding: 'App.usersController.selectedUser',
    tagName: 'span',
    didInsertElement: function () {
        $('h1').html('Edit User');
        document.title = 'Edit User';
    },
    showUsersList: function(event) {
        App.usersController.showUsersList();
    }
}).append();
2012-04-05 07:29
by sly7_7


1

I trimmed out some of your app-specific logic, but got your action helper working in this fiddle

Handlebars:

<script type="text/x-handlebars" data-template-name="user-edit">
    <p><a href="#" {{action "showUsersList"}}>Back</a></p>
</script>

<script type="text/x-handlebars" >
  {{view App.UserEditView}}
</script>​

JavaScript:

App = Ember.Application.create({});

App.UserEditView = Ember.View.extend({
    templateName: 'user-edit',
    tagName: 'span',
    showUsersList: function(event) {
        alert('hi');
    }
});​
2012-04-04 03:26
by Dan Gebhardt
Thanks Dan. I appreciate your help - Robert Beaupre 2012-04-04 18:49
Glad to help, Robert - Dan Gebhardt 2012-04-04 19:14