Chrome網絡開發者控制檯對頁面打開一個錯誤:淘汰賽 - 無法解析綁定
Uncaught Error: Unable to parse bindings.
Message: SyntaxError: Unexpected token .;
Bindings value: business.RegistrationViewModel.registerBusiness
我有一個簡單的商業登記形式: 我的商業登記按鈕數據綁定=「business.RegistrationViewModel.registerBusiness 「
我爲企業RegistrationViewModel看起來是這樣的:
var business = {};
business.RegistrationViewModel = function (business)
{
var me = this;
me.BusinessName = ko.observable('');
me.BusinessAddress = ko.observable('');
me.BusinessCity = ko.observable('');
me.BusinessState = ko.observable('');
me.BusinessZip = ko.observable('');
me.RegistrationEmail = ko.observable('');
};
我的註冊功能是這樣的:
business.RegistrationViewModel.registerBusiness = function() {
var me = this;
var business = ko.toJSON(this);
$.ajax({
url: "/RegisterBusiness",
type: 'post',
data: business,
contentType: 'application/json',
success: function (result) {
alert("An email has been sent to your email address.");
}
});
};
我applyBinding功能是這樣的:
$(document).ready(function() {
ko.applyBindings(new business.RegistrationViewModel());
});
我不是正確寫我registerBusiness功能?我迷失在這個實際的錯誤存在的地方。
'this'在此行'VAR業務= ko.toJSON(本);'獲取返回的功能不是你的viewmodel。當你在這條線上斷點時你會得到什麼? – alsafoo