这是我的注销点击事件:
logoutClicked: (event) ->
event.preventDefault()
console.log 'userPanel.logoutClicked -> event', event
console.info App.session
App.session.destroy
wait: true
success: (model, res) ->
console.log 'session.destroy.success -> model/res', model, res
error: (model, res) ->
console.log 'session.destroy.error -> model/res', model, res
这是我的会话模型:
class App.Model.Session extends Backbone.Model
initialize: ->
console.log 'Session.init'
urlRoot: '/session'
这是我的苗条后端路线:
$app->delete('/session', function () {
session_unset();
exit(true);
});
当我触发 logoutClicked 事件时,一切正常,但我无法通过我的萤火虫看到任何服务器通信(没有 DELETE 或 GET 到 /session ...)。
萤火虫输出:
userPanel.logoutClicked -> event Object { originalEvent=Event click, type="click", timeStamp=18807379, altri elementi...}
Session { cid="c1", attributes={...}, _changing=false, altri elementi...}
session.destroy.success -> model/res Session { cid="c1", attributes={...}, _changing=false, altri elementi...} null
正如您所见,没有触发 DELETE 请求...并且我从 session.destroy 成功回调中收到空 res...我是 Backbone 的新手,有什么建议吗?也许我必须设置 Backbone.sync?