0

问题是,当我在我的开发环境(Windows 7 64 位)中运行 Web 应用程序时,淘汰绑定按设计工作,但是当应用程序在 Heroku 上运行时,具有相同确切数据的相同页面给了我一个

未捕获的错误:无法解析绑定消息:ReferenceError:未定义 searchLink;绑定值:attr:{href:searchLink}

我正在使用淘汰映射器将 json 解析为所需的对象,ViewModel 是

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 -->    

我删除了与问题无关的函数和变量..

4

1 回答 1

0

解决了这个问题。意识到我们的 HTML 缩小模块删除了 html 标签,因此打破了淘汰赛

于 2013-02-26T21:55:09.197 回答