Last active
May 23, 2017 16:04
-
-
Save n1ru4l/a1ae6842f5d62604b67a71e43afc887d to your computer and use it in GitHub Desktop.
array not updating
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 { | |
times, | |
constant | |
} from 'lodash'; | |
const { | |
get, | |
set, | |
Component, | |
on, | |
A: EArray, | |
} = Ember; | |
export default Component.extend({ | |
answers: null, | |
answerCheckedStates: null, | |
onInit: on(`init`, function () { | |
const lengthAmount = this.get(`answers.length`) | |
const answerCheckedStates = times(lengthAmount, () => false) | |
this.set(`answerCheckedStates`, answerCheckedStates) | |
}), | |
actions: { | |
toggleStatus(index) { | |
const currentValue = get(this, `answerCheckedStates.${index}`) | |
console.log(`Current value`, currentValue) | |
set(this, `answerCheckedStates.${index}`, !currentValue) | |
const changedValue = get(this, `answerCheckedStates.${index}`) | |
console.log(`Changed value`, changedValue) | |
} | |
} | |
}); |
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'; | |
const { | |
A: EArray, | |
} = Ember; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
answers: EArray([ | |
{ id: 1, value: `Tomato` }, | |
{ id: 2, value: `Oranges` }, | |
{ id: 3, value: `Pineapple` }, | |
{ id: 4, value: `Sushi` }, | |
]) | |
}); |
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 nthChild(params/*, hash*/) { | |
return params[0][params[1]] | |
} | |
export default Ember.Helper.helper(nthChild) |
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", | |
"ember-lodash": "4.17.4", | |
"ember-paper": "1.0.0-alpha.19" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment