Last active
May 5, 2017 01:00
-
-
Save lennyburdette/1709894728e7e18207025b58b1d99c1b to your computer and use it in GitHub Desktop.
ff select options debugging
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({ | |
change(e) { | |
this.sendAction('action', this.get(`options.${e.target.selectedIndex}`)); | |
}, | |
didReceiveAttrs() { | |
Ember.run.scheduleOnce('afterRender', () => { | |
this.$('select')[0].value = this.get('options').indexOf(this.get('value')); | |
}); | |
} | |
}); |
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({ | |
optionsA: Ember.computed(function() { | |
return [{ | |
name: 'A' | |
}, { | |
name: 'B' | |
}, { | |
name: 'C' | |
}, { | |
name: 'Create New' | |
}]; | |
}), | |
init() { | |
this.set('selectedValue', this.get('optionsA.2')); | |
}, | |
actions: { | |
update(newValue) { | |
if (newValue.name === 'Create New') { | |
const newThing = { name: 'I am new' }; | |
const original = this.get('optionsA'); | |
const newArray = original.slice(); | |
newArray.splice(original.length - 1, 0, newThing); | |
this.set('optionsA', newArray); | |
this.set('selectedValue', newThing); | |
} else { | |
this.set('selectedValue', newValue); | |
} | |
} | |
} | |
}); |
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 function eq([a, b]) { | |
return a === b; | |
} | |
export default Ember.Helper.helper(eq); |
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 function indexOf([haystack, needle]) { | |
return haystack.indexOf(needle); | |
} | |
export default Ember.Helper.helper(indexOf); |
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 function toString([value]) { | |
return String(value); | |
} | |
export default Ember.Helper.helper(toString); |
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