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 shows as undefined. data.materialNumber has a string value and self.materials loads correctly. Any help would be appreciated!
I'll try to include only the code needed...
My html:
<select class="materialSelect" data-placeholder="Choose Material..."
data-bind="options: materials,
value: material,
optionsText: function (item) { return item.description },
optionsValue: function (item) { return item.materialNumber },
chosen: materials,
chosenOptions: { width: '250px', search_contains: true }"></select>
My js:
function Mrs() {
var self = this;
self.materials = ko.observableArray();
self.material = ko.observable("");
bom.hubs.mrs.server()
.getMaterialsForAuthorizedPlants(lastSection)
.done(function (data) {
data.materials.unshift({});
self.material(data.materialNumber);
self.materials(data.materials);
});
};
(function (bom) {
"use strict";
bom.hubs.done(function() {
ko.applyBindings(new Mrs());
});
})(bom);