0
정의되지 않음. 그러나 첫 번째 페이지 변경 후, 나는 오류 얻을 : 당신은 범위에 문제가있어백본 JS Turbolinks는 내 코드의 모습을 어디 백본 JS와 Turbolinks 응용 프로그램이 문제
Uncaught ReferenceError: AppRouter is not defined
정의되지 않음. 그러나 첫 번째 페이지 변경 후, 나는 오류 얻을 : 당신은 범위에 문제가있어백본 JS Turbolinks는 내 코드의 모습을 어디 백본 JS와 Turbolinks 응용 프로그램이 문제
Uncaught ReferenceError: AppRouter is not defined
을이 작동합니다 : 당신은 DOM-의 범위 내에서 AppRouter을 선언했다
var AppRouter = Backbone.Router.extend({
routes: {
'': 'music',
'song/:musicID': 'songList'
},
...FUNCTIONS GO HERE
});
$(function() {
var appRouter = new AppRouter();
Backbone.history.start({ pushState: true, hashChange: false });
});
$(document).on('page:load', function(){
Backbone.history.stop();
var appRouter = new AppRouter();
});
ready 콜백을 호출하고 정의되지 않은 'page : load'콜백 내에서이를 참조하려고했습니다. 위의 코드에서 전역 범위에 정의되어 있으므로 둘 다 액세스 할 수 있습니다.