# in pjax:success callback
@callController = ->
if window.currentController != (controller = window.getController())
window.currentController = controller
window[controller + "_controller"].call()
# part of window.getController()
# return "users", for example
@getController = ->
window.location.pathname.split("/")[1]
# controller code
@users_controller = ->
console.log "code from users_controller"
如何为每个控制器代码编写析构函数?例如,当users
更改为posts
我需要执行时@users_controller.destroy()
。
或者告诉我这个问题的另一个解决方案:)