-2
我有一個頁面上有樹視圖控制點擊樹視圖節點我試圖改變視圖模型,然後查看,但它沒有更新視圖。如何更新或刷新ViewModel數據,然後再查看。使用淘汰賽js
代碼
var emp = new EmpViewModel();
$(document).ready(function() {
var EmpViewModel = function() {
var self = this;
self.EmpNo = ko.observable("0");
self.EmpName = ko.observable("");
self.Salary = ko.observable("");
self.DeptName = ko.observable("");
self.Designation = ko.observable("");
var EmpData = {
EmpNo: self.EmpNo,
EmpName: self.EmpName,
Salary: self.Salary,
DeptName: self.DeptName,
Designation: self.Designation
};
self.Employees = ko.observableArray([]);
ko.applyBindings(new EmpViewModel());
});
function OnTreeviewNodeSelect(e) {
emp.EmpNo(e.EmpNo),
emp.EmpName(e.EmpName),
emp.Salary(e.Salary),
emp.DeptName(e.DeptName),
emp.Designation(e.Designation)
ko.applyBindings(emp);
}
感謝
以代碼和實例的方式提供更多內容是很有用的。 – jtromans