I'm new to Ember and I'm writing my first app. I'm working with version 1.13.13.
What I'm trying to do is to override a function from a class that I comes from version 0.2.1 of a package I installed (http://ift.tt/2aGz7ea).
Here is the code I'm using:
`import Ember from 'ember'`
`import MultiselectCheckboxOptionComponent from
'ember-multiselect-checkboxes/components/multiselect-checkbox-option'`
multiselectCheckboxesPatch =
name: 'ember-multiselect-checkboxes-patch'
initialize: ->
MultiselectCheckboxOptionComponent.reopen
isSelected: Ember.computed 'value', 'selection', (_, checked) ->
if arguments.length > 1
selected = this.get('selection').contains(this.get('value'))
if checked and not selected
this.get('selection').addObject(this.get('value'))
else if not checked and selected
this.get('selection').removeObject(this.get('value'))
# Added this line to fix variant of http://ift.tt/2aSDm9V
@set('selection', Ember.copy(this.get('selection')))
this.get('selection')?.contains(this.get('value'))
`export default multiselectCheckboxesPatch`
But the issue I'm facing is that this.get('selection') seems to be undefined. I don't understand why since selection is an attribute from the class that I'm reopening. Also, I think this code used to work in older versions of ember since I got it from another project.
Thank you!
Aucun commentaire:
Enregistrer un commentaire