knockout无法绑定

yill0304 2016-11-28 03:02:21
var addressGroup;
function Address() {
var self = this;
self.name = ko.observable();
self.isSaved = ko.observable(false);
self.save = function () {
return function () { alert(1); }
}
};
var otherGroup;
function Other() {
var self = this;
self.pwds = ko.observable();
self.isSaved = ko.observable(false);
self.save = function () {
return function () { alert(2); }
}
}

var model = {

address: ko.observable(),
other: ko.observable()
};

$(function () {
var address = new Address();
addressGroup = ko.validation.group(address);
addressGroup.showAllMessages(false);
model.address(address);

var other = new Other();
otherGroup = ko.validation.group(other);
otherGroup.showAllMessages(false);
model.other(other);
ko.applyBindings(model);
});
...全文
112 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,903

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧