[英]Knockout Unable to parse bindings only when running app on Heroku
問題是,當我在開發環境(Windows 7 64位)中運行Web應用程序時,敲除綁定按設計工作,但是當應用程序在Heroku上運行時,具有相同數據的相同頁面也給我一個提示。
未捕獲的錯誤:無法解析綁定消息:ReferenceError:未定義searchLink;默認值為0。 綁定值: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':'noemail502e6c13e4b0831b62e6896e@...','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 -->
我刪除了與問題無關的函數和變量。
解決了問題。 意識到我們的HTML minify模塊刪除了html標簽,從而打破了淘汰賽
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.