我想在骨干应用程序启动之前发送/login
之类的身份验证调用,并希望根据响应设置current_user。
我面临的问题是当我在主project.js.coffee
发送ajax调用之后,在获得认证请求控制器的show方法被调用的响应之前,我无法获得当前用户。每个控制器都会发生这种情况。
我在project.js.coffe
app = do (Backbone, Marionette) ->
App = new Marionette.Application
App.rootRoute = 'dashboard'
App.Radio = Backbone.Radio
App.canvasChannel = Backbone.Radio.channel('page-builder')
mainRegion = Marionette.Region.extend el: "#main-region"
App.addRegions
mainRegion: mainRegion
modalRegion: '#modal-region'
App.addInitializer ->
App.module('Dashboard').start()
App.on 'before:start', (options) ->
# I want to send HTTP request here
App.request('set:current:user', Project.current_user)
$.extend(@Project, app)
信息中心代码controller.js.coffee
:
@Project.module 'Dashboard', (Dashboard, Backbone, Marionette, $, _) ->
Dashboard.Controller =
initialize: ->
console.log("Inside initialize request");
show: (tab, refresh = false, scrollTop = 0) ->
# Here I want to get the current user
有什么建议吗?