モーダルを持つ非常に基本的なバックボーン JS アプリケーションがあります。現在、ルーターはモーダルを次のように表示します。
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: ->
# ?
これは問題なく動作しますが、ウィンドウの履歴と戻るボタンを選択したユーザーを処理する方法がわかりません (つまり、戻るをクリックしたときにモーダルを破棄する方法)。誰かが最善のアプローチについて何か考えを持っていますか? ありがとう。