   oauthEndPoint: "#{Config.oauthEndpoint}authorize?client_id=#{@::clientId}&response_type=token&redirect_uri=#{Config.oauthRedirectUri}"
 
   @setup: ->
-    $(document).ajaxError (event, xhr, ajaxSettings, thrownError) =>
+    $(document).on 'ajaxError', (event, xhr, ajaxSettings, thrownError) =>
       console.log("Global ajaxError", arguments)
       console.log("XHR.status", xhr.status)
       console.log("XHR.responseText", xhr.responseText)

          return unless token
          @saveToken token
          Spine.trigger 'login' if @token
    else
      window.location = @::oauthEndPoint


    @token

  @logout: ->
    if window.cordova
      if window.device.platform.indexOf('Android')!=-1
        navigator.app.loadUrl Config.oauthEndpoint.replace('/oauth/','/accounts/sign_out/')
      else
        window.location = Config.oauthEndpoint.replace('/oauth/','/accounts/sign_out/')
    else if window.forge
      forge.tabs.openWithOptions
        url: Config.oauthEndpoint.replace('/oauth/','/accounts/sign_out/')
