Skip to content Skip to sidebar Skip to footer

Knockout Value Not Being Set In Function

I am having a problem when trying to get self.material (an observable) to load a value from within a function. When trying to load the observable in the select with a value, it sh

Solution 1:

TL;DR Assign self.materials before self.material


The options binding will attempt to synchronise the selected option with the value, but when you assign self.material there are NO options, so it resets the material value back to undefined.

When you then set self.materials, the options then rebuilds, but self.material is now undefined.

If you swap the assignments, then the select options will be available when the material observable is set.

Post a Comment for "Knockout Value Not Being Set In Function"