For some reason I want to call knockout method in jQuery.
Knockout viewModel is already binding. I don't know how to call it in jQuery.
Here is my code.
$(document).ready() {
form_submit();
}
function form_submit() {
var form = $('#form');
var serializedData = form.serialize();
$.get("{% url 'search:search' %}", serializedData, function(response) {
AppViewModel.count(response.count); // I tried this, it says undefined is not a function
//Then I tried:
var newModel = new AppViewModel();
newModel.count(response.count); //No errors, but UI doesn't change. I know it's because I'm not binding it. But I don't think I can binding it, because only 1 ko.binding allowed.
}
function AppViewModel() {
var self = this;
self.count = ko.observable(count); //Assume I initially assigned some value to count.
//some other code below not related to this question.
}
ko.applyBindings(new AppViewModel());
Hope someone can help. Thanks!