I have a observable defined inside a object literal of a knockout viewmodel . Now when I ran the application .Its unable to access the observable .
$(function () {
var viewModel = {
Folders: ['Inbox', 'Archive', 'Sent', 'Spam'],
Title: ko.observable("My View Model Test"),
SelectedFolder: ko.observable(),
Mails: ko.observableArray(),
SelectedMail: ko.observable(),
SelectedChoices: ko.observable(false),
navigate: function (folder) {
SelectedFolder(folder);
$.ajax({
url: "/Api/MailBox",
data: { folder: folder },
success: function (data) {
self.Mails(data);
},
statusCode: {
404: function () {
console.log("No Mails");
}
}
});
}
};
}
when I have bind the click event to navigate
function . It says SelectedFolder
is undefined . Can someone tell me why is it unable to access the SelectedFolder
observable inside the navigate
function ?