Hey all I need a hand here. I've been at this for a few hours now and I just can't find how this code is bringing back the old value(s).
const onCheck = (e) => {
let listBox = $("#Sources").data("kendoListBox"),
treeView = $("#availableSources").data("kendoTreeView"),
selection = [],
getSelection = (items) => {
items.forEach(item => {
if (item.hasChildren) {
getSelection(item.items);
} else if (item.checked) {
selection.push(item);
}
});
};
if (e.node.attributes[3].value == "false") {
listBox.remove(listBox.items());
$("#Sources option[value='" + listBox.dataSource._data[0].value + "']").remove();
//selection.pop(listBox.dataSource._data[0]);
} else {
getSelection(treeView.dataSource.data());
if (selection.length) {
selection.forEach(item => {
listBox.add({
text: item.text,
value: item.id
});
});
}
}
}
As an example say I checked the item Github and it places it into the listbox just fine. It also adds the ID of the item to the hidden select component.
Now say I uncheck that item now:
Great! It removed the item from the listbox and also from the hidden select component. However though, when I chose another item, say GitHubIssues I am presented with not only that item in the listbox but the pervious item is placed into the select component.
It has the correct item in the listbox but I am unsure as to why its keeping the previous value(s)?