Я использую магистраль с requirejs, я запускаю событие в глобальном объекте приложения и устанавливаю, когда приложение запускает дескриптор, но по какой-то причине событие не получает зацепку здесь, это код из приложения ,Невозможно запустить базовую модель события
main.js
require([
"app",
"router",
"modules/facebookLogin"
],
function(app, Router,FacebookLogin) {
// Define your master router on the application namespace and trigger all
// navigation from this instance.
app.router = new Router();
app.currentFacebookSession = new FacebookLogin.Model();
app.currentFacebookSession.on({
'facebook:unauthorized': function() {
//app.router.navigate('', true);
},
'facebook:disconnected': function() {
//app.router.navigate('', true);
},
'facebook:connected': function() {
//app.router.navigate('events', true);
console.log('EVENTS');
}
});
// Trigger the initial route and enable HTML5 History API support, set the
// root folder to '/' by default. Change in app.js.
Backbone.history.start({ pushState: true, root: app.root });
//Init facebook
...
и модель facebookLogin.js
// Facebookuser module
define(["app", "facebookSDK"],
// Map dependencies from above array.
function(app,FB) {
// Create a new module.
var FacebookLogin = app.module();
// Default Model.
FacebookLogin.Model = Backbone.Model.extend({
initialize: function (attributes, options) {
options || (options = {});
this.options = _.defaults(options, this.defaultOptions);
this.facebookInitialize();
_.bindAll(this, 'onLoginStatusChange');
FB.Event.subscribe('auth.authResponseChange', this.onLoginStatusChange);
},
.....
onLoginStatusChange: function (response) {
if (this._loginStatus === response.status) return false;
var event;
if (response.status === 'not_authorized') {
event = 'facebook:unauthorized';
} else if (response.status === 'connected') {
event = 'facebook:connected';
if (this.options.autoFetch === true) this.fetch();
} else {
event = 'facebook:disconnected';
}
this.trigger(event, this, response);
this._loginStatus = response.status;
},
На отлаживать дело доходит до запуска и выполнения триггера со следующим параметром.
this.trigger(event, this, response);
это =
child
_changes: Object
_escapedAttributes: Object
_pending: Object
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c0"
id: ""
onLoginStatusChange: function bound() {
options: Object
__proto__: Surrogate
событий = "facebook:connected"
и ответ правильный объект
Я заменил app.Router.nagigate сейчас отладить проблему с log, но это никогда не бывает, Любые идеи, почему?