Hi,
I am trying to implement a filtering in my knockout application using a AJAX get and i want to update only one of the many observables in the viewmodel.
This is my viewmodel here in JS
function containerViewModel() {
mainViewModel = this;
mainViewModel.isBusy = ko.observable(false);
mainViewModel.errorMessage = ko.observable("");
mainViewModel.containerModel = ko.observable(
{
HomeSettings: ko.observable(),
Employee: ko.observable({ HeaderText: '', BodyText: '', FooterText: '' }),
Class: ko.observable({ HeaderText: '', BodyText: '', FooterText: '' }),
Degree: ko.observable({ HeaderText: '', BodyText: '', FooterText: '' }),
Specialization: ko.observable({ HeaderText: '', BodyText: '', FooterText: '' }),
IDEAData: ko.observable({ HeaderText: '', BodyText: '', FooterText: '' })
}
);
GET_AllContainer(mainViewModel);
}
Each of these observables are shown in different tabs and each tab has filter buttons. When i click the filter button from any tab, i fetch the data using ajax call. But the problem is am getting the whole data and binding to the viewmodel as this
function GET_FilteredContainer(mainView, filterText, productID, FilterID) {
mainViewModel.isBusy(true);
$.ajax({
url: hostApi + api_GetAllContainer,
contentType: "json",
data: { FilterLinkIds: filterText, ProductID: productID },
success: function (result) {
mainView.containerModel(result);
SetFilterButtonCSS(productID, FilterID);
ProductReportsNotFound(result);
mainViewModel.isBusy(false);
},
error: function (result) {
mainViewModel.errorMessage(result);
mainViewModel.isBusy(false);
}
});
}
But this means it will clear the filter of other tabs. So is there any way i can update only the required observable only
Thanks