2014-06-23 1 views

답변

1

을이 작동합니다 : 당신은 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'콜백 내에서이를 참조하려고했습니다. 위의 코드에서 전역 범위에 정의되어 있으므로 둘 다 액세스 할 수 있습니다.