我有一个非常基本的Backbone JS应用程序,它具有模态。目前,我的路由器提出了模态如下:Modals的骨干路由器
class App.Routers.Router extends Backbone.Router
routes:
"modal" : "modal"
modal: ->
view = new App.Views.Modal.New()
$('#shared').html(view.el)
view.render()
view.show()
return
class App.Views.Sessions.New extends Backbone.View
template: Handlebars.templates["backbone/templates/modals"]
initialize: (options) ->
super(options)
render: ->
$(@el).html(@template())
$('.modal', @el).modal()
$('.modal', @el).on 'hidden', @cleanup
return @
show: ->
$('.modal', @el).modal('show')
hide: ->
$('.modal', @el).modal('hide')
cleanup: ->
# ?
这工作得很好,但我不清楚如何处理窗口的历史和选择后退按钮用户(即如何我拆毁模态上单击后退)。有没有人对最佳方法有任何想法?谢谢。