我使用knockoutjs将数据绑定到表,我想在用户点击更新对象。 这里是我的代码
var Books = [{Book:"Harry Potter",Author:"J.K rowling"},{Book:"5 Point Someone",Author:"Chetan Bhagat"},{Book:"I too had a love story",Author:"Ravinder Singh"}];
var appViewModel = function() {
this.firstName = ko.observable("Amit");
this.Books = ko.observableArray([]);
this.Books(Books);
this.updateBook = function() {
this.Book("Harry Potter and Prisoner of Azkaban");
}
};
ko.applyBindings(appViewModel);
但是,出现错误:“遗漏的类型错误:字符串是不是一个函数”。 如何解决这个问题?
请参阅: http://jsfiddle.net/jVQY8/8/