ember-addons / bootstrap-for-ember

Bootstrap for Ember.js
http://ember-addons.github.io/bootstrap-for-ember
Apache License 2.0
704 stars 103 forks source link

button groups with 'clicked' meta data property not working #117

Open j6er8er opened 10 years ago

j6er8er commented 10 years ago

I can't get any clicks from button group buttons to trigger my controllers action.
In my template: {{ bs-btn-group size="1g" contentBinding="buttons" selectedBinding="selectedAction" }}

in my controller: buttons : [ Ember.Object.create({title: 'Create', type: 'primary', small: true, clicked:'editButtonClicked'}), Ember.Object.create({title: 'Delete', type: 'danger',small: true}), Ember.Object.create({title: 'Save', type: 'success',small: true})], actions : { editButtonClicked : function() { console.log("clicked!!!"); }

I can get regular buttons to work and when I look at the ember-debugger, they show up as a bsButton object whereas my button group buttons are just a plain old object.

j6er8er commented 10 years ago

I got this working by adding an observer to 'selectedAction' like so:

editButtonClicked : function() { var sel = this.get('selectedAction'); if(Ember.isNone(sel)) return; this.send(sel.clicked) }.observes('selectedAction'),

ember-addons commented 10 years ago

@j6er8er I'll check but you can just observes the selected property instead of setting all buttons click events.