Checkbox helper and firing objectcontroller change function


#1

Hello,

I was wondering if I could get some assistance on this stack overflow question. The ‘change=‘someFunction’’ answer does not work, and the linked Stack Overflow question provides an overly complex solution to a very simple problem: all I want is for the item controller method to fire whenever the user checks or unchecks the button. The method it is supposed to call is very simple: it just saves the data back to the store. This is very frustrating because it’s a simple thing that can usually be solved with one or two lines of code.

http://stackoverflow.com/questions/28461450/ember-checkbox-input-helper-cannot-user-on-property/


#2

One way would be to bind the checkboxes using data binding to the checked value and then observing that value.

Your code would look something like this

{{input type="checkbox" name="isChecked" checked=isChecked}}

and in the controller

isCheckedObserver: function(){
  var isChecked = this.get('isChecked');
  // DO STUFF!
}.observes('isChecked')

In general I’ve found when I’m trying to use events (not including actions), it becomes more difficult. Things seem to go easier when I use data bindings.

– OOPS just reread your question and noticed you’re already binding checked to your users is_disabled value. You can observe that value instead of the isChecked I mentioned above.