I'm trying to reset a knockout observable array in my view model to contain nothing, yet I'm being stonewalled at every turn. When it is defined, I set it empty:
self.currentPeople = ko.observableArray([]);
Yet if I try to alter it down the page:
self.currentPeople.removeAll();
I get the exception:
Uncaught TypeError: undefined is not a function
Even if I do a safe check to see if it exists and then set it:
if (self.currentPeople ) {
self.currentPeople.removeAll();
} else {
self.currentPeople = ko.observableArray([]);
}
I still receive the same error. What am I doing wrong?