-
-
Save camskene/2d8f14346af731535a4fc72a4a4e672c to your computer and use it in GitHub Desktop.
Toggle local dropdown
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({ | |
configuration: undefined, | |
actions: { | |
onExpand(item) { | |
item.toggleProperty('isExpanded'); | |
}, | |
}, | |
}); |
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({ | |
configuration: undefined, | |
actions: { | |
onExpand(item) { | |
Ember.set(item, 'isExpanded', !item.isExpanded); | |
}, | |
}, | |
}); |
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({ | |
}); |
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({ | |
tagName: 'button', | |
}); |
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({ | |
state: undefined, | |
isExpanded: Ember.computed.readOnly('state.isExpanded'), | |
classNames: ['my-component'], | |
actions: { | |
toggle() { | |
this.toggleProperty('isExpanded'); | |
if (!this.get('isExpanded')) { | |
return; | |
} | |
this._setupClickHandler(); | |
}, | |
}, | |
willDestroyElement() { | |
this._super(...arguments); | |
this._teardownClickHandler(); | |
}, | |
_setupClickHandler() { | |
$(document).on(`click.${this.elementId}`, (e) => { | |
if (!e.target.closest(`#${this.elementId}`)) { | |
this.set('isExpanded', false); | |
this._teardownClickHandler(); | |
} | |
}); | |
}, | |
_teardownClickHandler() { | |
$(document).off(`click.${this.elementId}`); | |
}, | |
}); |
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', | |
myAccordianConfig: Ember.computed(function() { | |
return [ | |
{ | |
label: 'numero uno', | |
isExpanded: false, | |
children: [ | |
{ | |
label: '1.1', | |
isExpanded: true, | |
} | |
] | |
}, | |
{ | |
label: '222', | |
isExpanded: false, | |
}, | |
]; | |
}), | |
actions: { | |
onClickButton() { | |
this.get('myAccordianConfig').setEach('isExpanded', 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; | |
} | |
.my-component button { | |
height: 30px; | |
width: 100%; | |
} |
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": true, | |
"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