0

Hello Stack Overflowers!

Given:

{{#each user in model itemController="user"}}
   <tr>
  ....
  <td>{{ input type="checkbox" action="acceptChanges" on="click" class="toggle" checked=user.is_disabled }}</td>

Then when rendering the view an error is thrown:

Uncaught TypeError: string is not a function

However, removing the 'on' property, such that the mark-up is:

<td>{{ input type="checkbox" action="acceptChanges" class="toggle" checked=user.is_disabled }}</td>

Then the page renders. My goal is to bind the "acceptChanges" controller method to changing this value. "acceptChanges" is an ObjectController method that simply saves the object in the store.

Here is the objectcontroller method I am trying to call:

AdminApp.UserController = Ember.ObjectController.extend({

    actions: {
        editUser: function(){
            this.set('isEditing', true);
        },
        acceptChanges: function(){
            console.log("accepting changes");
            this.set('isEditing', false);
            var model = this.get('model');
            model.save();
        }
    },
RedMage
  • 1,126
  • 1
  • 9
  • 21

1 Answers1

0

{{action="acceptChanges" on="click"}} won't work. Try {{change="acceptChanges"}}. See this link to Ember's documentation for a more detailed explanation. Checkboxes accept the change event, it may suit your case better. If that doesn't work, try the accepted answer on this post: Trigger an action on the change event with Ember.js checkbox input helper?

Community
  • 1
  • 1
Eddie Prislac
  • 145
  • 1
  • 10