Created
March 20, 2017 15:23
-
-
Save validkeys/42fc3f6248bdcbf4862ef4a8059b1cc7 to your computer and use it in GitHub Desktop.
Simple 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({ | |
| "on-select": "someAction", | |
| emptyText: "Please select an option", | |
| options: null, | |
| selected: null, | |
| showOptionsContainer: false, | |
| wrappedOptions: Ember.computed('options.[]','selected', function() { | |
| var _this = this; | |
| return Ember.A(this.get('options').map(function(item){ | |
| return Ember.Object.create({ | |
| value: item, | |
| selected: item === _this.get('selected') | |
| }); | |
| })); | |
| }), | |
| actions: { | |
| toggleOptionsContainer: function() { | |
| this.toggleProperty('showOptionsContainer'); | |
| }, | |
| select: function(option) { | |
| this.sendAction("on-select", option); | |
| } | |
| } | |
| }); |
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', | |
| dropdownOptions: ["Kyle","Tarun"], | |
| dropdownSelected: null, | |
| actions: { | |
| selectOption: function(option) { | |
| console.log("seeting value to", option); | |
| this.set('dropdownSelected', option); | |
| } | |
| } | |
| }); |
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; | |
| } | |
| .dropdown { | |
| border: #eee 1px solid; | |
| padding: 5px 10px; | |
| } | |
| .optionsContainer { | |
| border: #eee 1px solid; | |
| } | |
| .optionsContainer > div { | |
| padding: 5px; | |
| border-bottom: #eee 1px solid; | |
| } |
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 function destroyApp(application) { | |
| Ember.run(application, 'destroy'); | |
| } |
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 Resolver from '../../resolver'; | |
| import config from '../../config/environment'; | |
| const resolver = Resolver.create(); | |
| resolver.namespace = { | |
| modulePrefix: config.modulePrefix, | |
| podModulePrefix: config.podModulePrefix | |
| }; | |
| export default resolver; |
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'; | |
| import Application from '../../app'; | |
| import config from '../../config/environment'; | |
| const { run } = Ember; | |
| const assign = Ember.assign || Ember.merge; | |
| export default function startApp(attrs) { | |
| let application; | |
| let attributes = assign({rootElement: "#test-root"}, config.APP); | |
| attributes = assign(attributes, attrs); // use defaults, but you can override; | |
| run(() => { | |
| application = Application.create(attributes); | |
| application.setupForTesting(); | |
| application.injectTestHelpers(); | |
| }); | |
| return application; | |
| } |
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 resolver from './helpers/resolver'; | |
| import { | |
| setResolver | |
| } from 'ember-qunit'; | |
| setResolver(resolver); |
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.11.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.11.0", | |
| "ember-data": "2.11.0", | |
| "ember-template-compiler": "2.11.0", | |
| "ember-testing": "2.11.0" | |
| }, | |
| "addons": {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment