lundi 5 octobre 2015

Ember component handling button click

I am creating a component that extends button I am looking for a way to handle a button click event in Ember 1.13.0. I tried that following code but no luck

//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"}}

Aucun commentaire:

Enregistrer un commentaire