Created
November 21, 2018 17:22
-
-
Save quincyle/b9711006202d12d6d5b473c5a2d55afe to your computer and use it in GitHub Desktop.
js select prev/next
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({ | |
classNameBindings: ['active'], | |
activeObserver: Ember.on('init', Ember.observer('active', function (){ | |
Ember.run.scheduleOnce('afterRender', () => { | |
const prevDivider = $(this.element.closest('.divider')).prev('.divider') | |
const nextDivider = $(this.element.closest('.divider')).next('.divider') | |
console.log(nextDivider) | |
if (this.active) { | |
prevDivider.addClass('before-active') | |
nextDivider.addClass('after-active') | |
} else { | |
prevDivider.removeClass('before-active') | |
nextDivider.removeClass('after-active') | |
} | |
}) | |
})) | |
}); |
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({ | |
appName: 'Ember Twiddle', | |
activeFoo: false, | |
activeBar: false, | |
activeBiz: false, | |
actions: { | |
activeFoo () { | |
this.setProperties({ | |
activeFoo: true, | |
activeBar: false, | |
activeBiz: false | |
}) | |
}, | |
activeBar () { | |
this.setProperties({ | |
activeFoo: false, | |
activeBar: true, | |
activeBiz: false | |
}) | |
}, | |
activeBiz () { | |
this.setProperties({ | |
activeFoo: false, | |
activeBar: false, | |
activeBiz: true | |
}) | |
} | |
} | |
}); |
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 { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.active { | |
color: red; | |
} | |
.before-active { | |
background-color: pink; | |
} | |
.after-active { | |
background-color: yellow; | |
} |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment