点击余烬组件处理按钮



我正在创建一个扩展按钮的组件,我正在寻找一种方法来处理Ember 1.13.0中的按钮单击事件。我尝试了下面的代码,但没有运气

//custom-button.js
export default Ember.Component.extend({
tagName: 'button',
attributeBindings: ['autofocus', 'accesskey', 'form', 'formaction', 'formenctype', 'type',
    'formmethod', 'formnovalidate', 'formtarget', 'name', 'value', 'contenteditable', 'contextmenu', 'dir',
    'draggable', 'dropzone', 'hidden', 'id' ,'lang', 'spellcheck', 'style', 'tabindex', 'title', 'translate',
    'disabled', 'role', 'targetForm'],
type: 'button',
click: function() {
    alert('clicking');
    this.sendAction();
}, 
//edit.hbm 
{{mbs-custom-button class="btn btn-primary" role="button" label=(t 'action.save') action="save"}}

从attributeBindings中删除id attr可以修复您的问题。参见:http://ember-twiddle.com/5e253f7e36b8eb0fe015

最新更新