6
따라야 할 것이 있습니다 Organizing your application using Modules (require.js 라우팅 작동 방식을 이해하는 데 어려움을 겪고 있습니다.Backbone.js 라우터 이벤트 바인딩이 실행되지 않습니다.
나는 인덱스 작업 바인딩 간단한 얻을 수 없습니다 페이지는 아무것도 넣지 않은
// Filename: router.js
define([
'jquery',
'underscore',
'backbone',
'views/projects/list'
], function ($, _, Backbone, ProjectListView) {
var AppRouter = Backbone.Router.extend({
routes: {
// Define some URL routes
'': 'index'
}
});
var initialize = function() {
var app_router = new AppRouter();
app_router.on('index', function() {
alert("index"); // this never gets called
});
Backbone.history.start();
return app_router;
};
return {
initialize: initialize
};
});
발생합니다. 이것은 작동하지만 :
// Filename: router.js
define([
'jquery',
'underscore',
'backbone',
'views/projects/list'
], function ($, _, Backbone, ProjectListView) {
var AppRouter = Backbone.Router.extend({
routes: {
// Define some URL routes
'': 'index'
},
index: function() { alert("works"); }
});
var initialize = function() {
var app_router = new AppRouter;
Backbone.history.start();
return app_router;
};
return {
initialize: initialize
};
});
나는 뭔가가 부족합니까?
감사 남자, 나는 모든 금요일 직장에서 이것에 어려움을 겪고 지금은 빛을 본 적이 있었다) – Puigcerber
@Fdr에 http : // 유래. co.kr/questions/20017210/router-js-function-not-executed 여기서 도와 줄 수 있어요 :) 고마워요. – CodeGuru