gpt4 book ai didi

ember.js - 在任何路由之上路由模态

转载 作者:行者123 更新时间:2023-12-02 03:40:00 24 4
gpt4 key购买 nike

我目前正在尝试在我的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com