Created
September 18, 2017 13:12
-
-
Save iamdtang/388048e55a335dafd1bfa421f4128489 to your computer and use it in GitHub Desktop.
checkbox list
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 { Component, computed } = Ember; | |
export default Component.extend({ | |
tagName: 'ul', | |
attributeBindings: ['data-test-hook'], | |
checkedItemsSet: computed('checkedItems.length', function() { | |
if (this.get('checkedItems')) { | |
return new Set(this.get('checkedItems').toArray()); | |
} | |
return new Set(); | |
}), | |
actions: { | |
onCheck(item) { | |
let checkedItemsSet = this.get('checkedItemsSet'); | |
if (checkedItemsSet.has(item)) { | |
checkedItemsSet.delete(item); | |
} else { | |
checkedItemsSet.add(item); | |
} | |
this.get('onChecked')(Array.from(checkedItemsSet)); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment