2013-04-14 3 views
0
여기

를 사용하여 내 코드입니다 : -오류 backbone.js에게 라우터

<!doctype html> 
<html> 
<head> 
    <title></title> 
</head> 
<body> 
    Everything related to routers.... 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"> </script> 
    <script src="../underscore-min.js"></script> 
    <script src="../backbone-min.js"></script> 
    <script type="text/javascript"> 

     var Router = Backbone.Router.extend({ 
     routes: { 
      "foo/:bar" : "paramtest", 
      "*action" : "func" 
     }, 
     func: function (action) { 
      console.log(action); 
     }, 
     paramtest:function (p) { 
      console.log(p); 
     } 
     }); 

     new Router(); 
     Backbone.history.start(); 
    </script> 
</body> 
</html> 

catch되지 않은 형식 오류 : 개체 # 백본 - min.js '에'있는 방법이 없습니다 : 1 h.extend.start 백본 분 의 .js : 1 (익명 함수)

+0

jQuery와 같은 이전 버전을 사용하는 이유는 무엇입니까? –

답변

3

현재 등뼈가 this inside Backbone.history.start 포함

if (this._hasPushState) { 
    Backbone.$(window).on('popstate', this.checkUrl); 
} else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { 
    Backbone.$(window).on('hashchange', this.checkUrl); 
} else if (this._wantsHashChange) { 
    this._checkUrlInterval = setInterval(this.checkUrl, this.interval); 
} 

참고 $(window).on() 전화 (,321 0은 보통 jQuery 함수에 대한 네임 스페이스가있는 참조 일뿐입니다.) 여기서 오류가 발생합니다. jQuery 1.4.4를 사용하고 있지만 on method은 1.7 버전까지 jQuery에 추가되지 않았습니다.

    이 1.7 이상, 바람직하게는 최신 jQuery를에 jQuery를 업그레이드
  1. :

    당신은 두 가지 옵션이 있습니다.

  2. 백본을 jQuery의 on을 사용하지 않는 버전으로 다운 그레이드하십시오.

옵션 (2)에는 어떤 버전을 사용할 지 모르지만 옵션 (1)은 더 좋은 아이디어입니다.