레일을 사용하고 있습니다. 방금 backbone-rails
보석을 설치하고 here 지침을 따랐습니다. 내가 Backbone.history.start()
을 할 때Uncaught TypeError : Backbone.history.start()에서 'start'메서드를 undefined로 호출 할 수 없습니다.
, 나는이 오류가 :
Uncaught TypeError: Cannot call method 'start' of undefined
내가 Backbone.history.start()
는 당신이 this other SO question에 따라, 적어도 하나 개의 경로를 생성 할 때까지 호출 할 수 없습니다 것을 이해합니다.
class Lunchhub.Routers.RestaurantLocationsRouter extends Backbone.Router
initialize: (options) ->
@restaurantLocations = new Lunchhub.Collections.RestaurantLocationsCollection()
@restaurantLocations.reset options.restaurantLocations
routes:
"new" : "newRestaurantLocation"
"index" : "index"
":id/edit" : "edit"
":id" : "show"
".*" : "index"
가 왜이 오류가 점점 오전 : 그게 내가이 커피 스크립트 파일에 정의 된 여러 경로를 가지고 할 수 있기 때문에,하지만, 내 문제가 될 것 같지 않습니다?
편집 :
<div id="restaurant_locations"></div>
<script type="text/javascript">
$(function() {
window.router = new Lunchhub.Routers.RestaurantLocationsRouter({restaurantLocations: <%= @restaurant_locations.to_json.html_safe -%>});
Backbone.history.start();
});
</script>
'Backbone.history.start() '를 호출하기 전에 어떤 경로의 * 인스턴스 *를 만드시겠습니까? – jackwanders
http://jsfiddle.net/ambiguous/a5SLF/와 http://jsfiddle.net/ambiguous/a5SLF/1/의 동작을 비교하면, 두 번째 것은 '새로운 R'이고 첫 번째는 그렇지 않습니다. –
나는 생각한다. 내 코드를 포함하도록 수정했습니다. –