I have an array of objects called options
and each option object has a boolean called showThis
. In my html, I am using a repeater over the options
array, and I'm binding a checkbox to the showThis
property. I need to update the value of showThis
in a method, so that I can trigger a save whenever the value changes. However, absolutely no matter what I do, the value on screen will not update to reflect changing the value of showThis
in my method. Updating the value does nothing, and also using splice()
does nothing.
Here is my html:
<div class="row" repeat.for="option of options">
<div class="col">
<div class="form-group">
<div class="form-check">
<input click.delegate="checkChanged(option, $index)" checked.bind="option.showThis" type="checkbox">
<label class="form-check-label">
${option.friendlyName}
</label>
</div>
</div>
</div>
</div>
Here is my (current version) checkChanged
method:
checkChanged(option, optionIndex){
let self = this;
option.showThis = !option.showThis;
self.save();
}
I have also tried this version using splice()
, with no change:
checkChanged(option, optionIndex){
let self = this;
self.options.splice(optionIndex, 1);
option.showThis = !option.showThis;
self.options.splice(optionIndex, 0, option);
self.save();
}