Hello all.
I have an example of code, where I am trying to call an ajax function, like this:
var data = { . . .
filter: {
param1: ko.observable(),
param2: ko.observable(),
. . .
paramN: ko.observable()
}
}
function ViewModel() {
var self = this;
self.sendData = function() {
$.ajax("address", ko.mapping.toJS(data.filter)).done(function() { . . . })
}
}
data.filter observables are binded with many text fields in html.
ViewModel.sendData function will be called only by a click binding in a button, but my code is calling it whenever a data.filter changes.
On the one hand, is there a method to avoid ko.mapping.toJS create any dependencies?
On the other hand, ViewModel.sendData function is not an observable, but, I have read ko transforms functions into computed's. I tried to avoid it by including model and event parameters into its signature, but I can't get the solution.
Can you give me a hand with this, please?
Thanks a lot in advance.