0
問題是,當我在我的開發環境(Windows 7 64位)中運行Web應用程序時,敲除綁定按設計工作,但是當應用程序在Heroku上運行時具有相同確切數據的同一確切頁面給我一個Knockout無法僅在Heroku上運行應用程序時解析綁定
未捕獲錯誤:無法解析綁定 消息:ReferenceError:searchLink未定義; 綁定值:ATTR:{HREF:searchLink}
我現在用的是淘汰賽映射器解析JSON成需要的對象,該的ViewModels是
var CoachesViewModel = function(data){
var self = this;
ko.mapping.fromJS(data, mapping, this);
}
var PendingCoachModel = function(data){
var self = this;
ko.mapping.fromJS(data, mapping, this),
}
var mapping = {
'coaches': {
create: function(options) {
return new CoachesViewModel(options.data);
}
},
'pendingCoaches':{
create:function(options){
return new PendingCoachModel(options.data);
}
}
}
var viewModel = function(coaches,pendingCoaches){
var self = this;
ko.mapping.fromJS(coaches, mapping, this);
ko.mapping.fromJS(pendingCoaches, mapping, this);
}
var vm = new viewModel(${team.serializedCoaches()},${team.serializedPendingCoaches()});
ko.applyBindings(vm);
The json is
{'coaches':[{'email':'[email protected]','name':'Jim Smith','searchImgLink':'http://localhost:9000/...','searchLink':'http://localhost:9000...','userId':'502e6c4b...96e'}]}
'pendingCoaches':[{'notifyId':'512bd9b874062909605d1','user':{'email':'hdog_lbf50f9698ae4ol.com','name':'Bob Johnson(Obf.)','pendingUser':false,'searchImgLink':'http://localhost:9000..','searchLink':'http://localhost:9000...','userId':'502e6c41e4e691e2'}}]
<!-- ko foreach: coaches -->
<div class = 'tCoach'>
//this is where it breaks
<a data-bind="attr:{href:searchLink}"><img data-bind = "attr:{src:searchImgLink}" class = 'coachImage'/></a>
<div class = 'coachInfo'>
<p><a data-bind="attr:{href:searchLink},text:name" class = 'coachName'></a></p>
<p data-bind = "text:reducedEmail"></p>
<p data-bind="if:isHeadCoach">Head Coach</p>
</div>
<img data-bind="bindCoachDropdown:self,attr:{manId:userId}" class = 'hd_drop managers' src = '/public/images/dropdown_orange.png' />
</div>
<!-- /ko -->
我刪除和變量是不相關的功能問題..