Last active
March 21, 2021 21:19
-
-
Save mariechatfield/3de2f20b58797f1add3214c49be7fcdd to your computer and use it in GitHub Desktop.
Events in Ember
This file contains hidden or 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({ | |
actions: { | |
stopPropagationAndLog(event) { | |
// This action has access to the DOM event and can call | |
// stopPropagation on it to prevent the event from bubbling. | |
event.stopPropagation(); | |
this.get('log')(`clickAttribute w/ stopPropagation of ${this.get('parentName')}`); | |
} | |
} | |
}); |
This file contains hidden or 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({ | |
actions: { | |
stopPropagationAndLog(event) { | |
// This action has access to the DOM event and can call | |
// stopPropagation on it to prevent the event from bubbling. | |
event.stopPropagation(); | |
this.get('log')(`onClick w/ stopPropagation of ${this.get('parentName')}`); | |
} | |
} | |
}); |
This file contains hidden or 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() { | |
this.sendAction(); | |
} | |
}); |
This file contains hidden or 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({ | |
logs: [], | |
actions: { | |
log(name) { | |
this.get('logs').pushObject(name); | |
}, | |
clearLogs() { | |
this.set('logs', []) | |
} | |
} | |
}); |
This file contains hidden or 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
body { | |
--padding-xsmall: 4px; | |
--padding-small: 8px; | |
--padding-medium: 16px; | |
--padding-large: 32px; | |
--color-text--dom: #F1EFF3; | |
--color-lightest--dom: #AE9FBB; | |
--color-light--dom: #6C5084; | |
--color-medium--dom: #350F57; | |
--color-dark--dom: #140620; | |
--color-text--ember: #080F10; | |
--color-lightest--ember: #C3F0F1; | |
--color-light--ember: #83D0D3; | |
--color-medium--ember: #56A3A6; | |
--color-dark--ember: #1D3738; | |
margin: var(--padding-medium); | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
pre { | |
font-size: 12px; | |
} | |
.wrapper { | |
display: flex; | |
} | |
.example-column { | |
flex: 1 0 auto; | |
max-width: 75%; | |
padding: var(--padding-xsmall); | |
} | |
.log-column { | |
flex: 0 1 25%; | |
padding: var(--padding-xsmall); | |
} | |
.log-content { | |
position: fixed; | |
top: 0; | |
padding: var(--padding-medium) 0; | |
} | |
.log-line { | |
padding: var(--padding-small) 0; | |
} | |
.helper { | |
padding: var(--padding-xsmall); | |
} | |
.parent { | |
padding: var(--padding-medium); | |
margin: var(--padding-large) 0; | |
max-width: 400px; | |
} | |
.parent--dom, | |
.helper--dom { | |
background-color: var(--color-medium--dom); | |
border: 1px solid var(--color-dark--dom); | |
color: var(--color-text--dom); | |
} | |
.parent--ember, | |
.helper--ember { | |
background-color: var(--color-medium--ember); | |
border: 1px solid var(--color-dark--ember); | |
color: var(--color-text--ember); | |
} | |
.child { | |
padding: var(--padding-small); | |
margin: var(--padding-small) 0; | |
cursor: pointer; | |
} | |
.child--dom, | |
.parent--dom .child--default { | |
background-color: var(--color-light--dom); | |
border: 1px solid var(--color-dark--dom); | |
color: var(--color-text--dom); | |
} | |
.child--ember, | |
.parent--ember .child--default { | |
background-color: var(--color-light--ember); | |
border: 1px solid var(--color-dark--ember); | |
color: var(--color-text--ember); | |
} | |
.child--invalid { | |
font-size: 10pt; | |
cursor: default; | |
} | |
.child--dom.child--invalid { | |
background-color: var(--color-lightest--dom); | |
} | |
.child--ember.child--invalid { | |
background-color: var(--color-lightest--ember); | |
} |
This file contains hidden or 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": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment