Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SelectionBinding for Checkbox in EmberJs

Does Emberjs provide selectionBinding for the checkbox to handle selected/checked checkbox options.

If yes, how to do it?

like image 263
user1338121 Avatar asked Apr 30 '12 12:04

user1338121


1 Answers

Bind to the checked property of Ember.Checkbox, see http://jsfiddle.net/5pnVg/:

Handlebars:

{{view Ember.Checkbox checkedBinding="App.objController.isChecked" }}

JavaScript:

App.objController = Ember.Object.create({
    isChecked: true,

    _isCheckedChanged: function(){
        var isChecked = this.get('isChecked');
        console.log( 'isChecked changed to %@'.fmt(isChecked) );
    }.observes('isChecked')
});​
like image 101
pangratz Avatar answered Nov 15 '22 10:11

pangratz