-2
У меня есть следующий код. Но я не уверен, почему видимый массив имен пуст. Он ничего не заполняет на html.пустой наблюдаемый массив - knockoutjs
function SolViewModel() {
names = ko.observableArray([{
"type": "optiongroup",
"label": "The Griffins",
"children": [
{ "type": "option", "value": "Peter", "label": "Peter Griffin" },
{ "type": "option", "value": "Lois", "label": "Lois Griffin" },
{ "type": "option", "value": "Chris", "label": "Chris Griffin" },
{ "type": "option", "value": "Meg", "label": "Meg Griffin" },
{ "type": "option", "value": "Stewie", "label": "Stewie Griffin" }
]
}
]);
$(function() {
$('#my-select').searchableOptionList({
data: function() {
var dataInSolFormat = names ; // this is empty
return dataInSolFormat;
}
});
});
}
ko.applyBindings(new SolViewModel());