我有一个计算的 observable,它使用 ko.toJS() 从视图模型中发布值(内部 observables)。内部可观察对象之一绑定到文本框。如何防止对文本框的更改自动触发计算出的 observable(即回发)?
function viewModel() {
var self = this;
self.SearchParams = {
OrderStatusID: ko.observable(),
OrderNumber: ko.observable(), // I don't want this observable to trigger the postback
OrderBy: ko.observable(),
OrderByDirection: ko.observable(),
PageIndex: ko.observable(),
PageSize: ko.observable()
};
// This computed observable automatically subscribes to every
// observable in self.SearchParams. How can I ignore changes to
// self.SearchParams.OrderNumber?
ko.computed(function () {
NS.post({
url: '/SomeUrl',
data: ko.toJS(self.SearchParams)
});
}).extend({ throttle: 1 });
}