Last active
September 15, 2017 02:06
-
-
Save pswai/59803287f0a988aecbb65c9d905025a5 to your computer and use it in GitHub Desktop.
Event objects in Ember
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
// Component-level event handler receives jQuery.Event | |
click(e) { | |
console.log('clickHookEvent', e); | |
}, | |
actions: { | |
// {{action 'actionHelper'}} does not receive event | |
actionHelper(e) { | |
console.log('actionHelperEvent', e); | |
}, | |
// onclick={{action 'closureAction'}} receives native Event | |
closureAction(e) { | |
console.log('closureActionEvent', e); | |
// It can be converted with `jQuery.event.fix` | |
// const fixedEvent = jQuery.event.fix(e); | |
// console.log('Fixed event', fixedEvent); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
actions: { | |
handle(e) { | |
console.log('Outside x-foo (application.hbs)', e); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.3.2", | |
"ember-template-compiler": "2.3.2", | |
"ember-testing": "2.3.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment