作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在尝试在我的 ember 应用程序中实现对可路由 模态的要求。目标是有一个选项卡式模式覆盖,其中每个选项卡都有自己的 URL(例如,/settings
、/settings/profile
或 /settings/billing
),但仍然显示 当前在后台的任何路线。
一个活生生的例子可能是 twitter.com的直接消息模态,但拥有它以便打开模态(并单击模态内的链接)更新应用程序的 URL。
我在尝试实现时遇到的主要困难是我的 socket 在“顶部”路线退出时断开连接。我在覆盖 Route#teardownViews
方面取得了一些初步成功,但我担心其他副作用。
编辑:为清楚起见,我确实在单独的 socket 中呈现模态:
SettingsRoute = Ember.Route.extend
renderTemplate: ->
@render
into: 'application'
outlet: 'modal'
这里是否可以采用总体上更好的方法?
最佳答案
这似乎在概念上可行(如果我不转换到消息或设置路由(我已将其定义为“模态”路由),我只会拆除“主要”路由的 View ):
Ember.Route.reopen
teardownViews: ->
@_super() unless @controllerFor('application').get('currentTransition.targetName') == 'messages.index'
actions:
willTransition: (transition) ->
controller = @controllerFor('application')
controller.set('currentTransition', transition)
transition.then ->
controller.set('currentTransition', null)
, ->
controller.set('currentTransition', null)
如果我取得任何其他进展,将回发。
关于ember.js - 在任何路由之上路由模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20689595/
我是一名优秀的程序员,十分优秀!