Last active
September 18, 2017 08:30
-
-
Save pswai/8d846fdc435a400ce3980e06528a9347 to your computer and use it in GitHub Desktop.
Ember Event Sequence
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({ | |
disabled: false, | |
click() { | |
if (!this.get('disabled')) { | |
console.log('stop-ember-bubble.js: '.padStart(25), 'Ember `click` event stopped'); | |
return false; | |
} | |
} | |
}); |
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({ | |
on: 'click', | |
disabled: false, | |
didInsertElement() { | |
this._super(...arguments); | |
if (!this.get('disabled')) { | |
Ember.$(this.get('element')) | |
.on(this.get('on'), e => { | |
console.log('stop-native-bubble.js: '.padStart(25), 'Native `click` event stopped'); | |
e.stopPropagation(); | |
}); | |
} | |
}, | |
willDestroyElement() { | |
Ember.$(this.get('element')) | |
.off(this.get('on'), e => e.stopPropagation()); | |
} | |
}); |
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({ | |
click() { | |
console.log('x-bar.js: '.padStart(25), '`click`, component-level'); | |
}, | |
actions: { | |
handleNative() { | |
console.log('x-bar.js: '.padStart(25), '`handleNative`, hooked up with `onclick`'); | |
}, | |
handleEmber() { | |
console.log('x-bar.js: '.padStart(25), '`handleEmber`, hooked up with just `{{action}}`'); | |
} | |
} | |
}); |
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({ | |
click() { | |
console.log('x-foo.js: '.padStart(25), '`click`, component-level'); | |
}, | |
actions: { | |
handleNative() { | |
console.log('x-foo.js: '.padStart(25), '`handleNative`, hooked up with `onclick`'); | |
}, | |
handleEmber() { | |
console.log('x-foo.js: '.padStart(25), '`handleEmber`, hooked up with just `{{action}}`'); | |
} | |
} | |
}); |
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: { | |
handleNative() { | |
console.log('application.js: '.padStart(25), '`handleNative`, hooked up with `onclick`'); | |
}, | |
handleEmber() { | |
console.log('application.js: '.padStart(25), '`handleEmber`, hooked up with just `{{action}}`'); | |
} | |
} | |
}); |
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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment