【问题标题】:How to make modals which have routes like Trello in Emberjs如何在 Emberjs 中制作具有 Trello 等路线的模态
【发布时间】:2016-07-03 08:27:46
【问题描述】:

我想知道我们如何制作有路线的模态。

在 Trello 中,每当您单击卡片时,路径都会从 abc.com/b/personal 更改为 abc.com/c/some-random-string,并且卡片会以模式打开。此外,当您关闭模式时,您会被重定向到上一个 url (abc.com/b/personal)。

我想知道如何使用 Emberjs 实现这一目标。

示例:https://trello.com/b/ezWgKsol/sales-enterprise-feature-requests-sample

【问题讨论】:

  • 与ember中的所有子路由一样。子路由模板为打开的模式保留标记。关闭时,您只需过渡到索引路线
  • modal 在 web 领域通常意味着只有一个大的、固定大小的 div 和灰色透明背景挂在你的页面上。
  • 请参阅此板 (trello.com/b/ezWgKsol/sales-enterprise-feature-requests-sample) 作为我想要的示例。

标签: ember.js routing ember-data ember-router


【解决方案1】:

这是我删除记录的模式(使用基础):

<div class="reveal" id="deleteLocationModal" data-reveal>
    <div class="row">
        <div class="columns">
            Are you sure you want to delete this location?
        </div>
    </div>
    <div class="row">
        &nbsp;
    </div>
    <div class="row">
        <div class="columns">
            <button id="cancelButton" class="secondary button" data-close type="button">Cancel</button>
            <button id="deleteButton" class="button" {{action "deleteLocation" model}} data-close type="button">Delete</button>
        </div>
    </div>
</div>

路由器在action hash中落下:

actions: {
    deleteLocation(model) {
        Ember.assert("Params must be provided", model);
        model.save().then(( /* response */ ) => {
            this.transitionTo('locations'); //locations is my index page.
            //flash message to inform the user of success.
        });
    }, (error) => {
        //handle error.
        //  display flash message
        //  rollback any dirty attributes

    });
}

希望对你有帮助,

杰夫

【讨论】:

  • 这将如何在新路线中打开?
  • 保存完成后,用户被转换到一个路由。在上面的示例中,我将它们路由到在我的情况下是我的应用程序的索引页面的位置。模式关闭并更新页面。
  • 我想要的是在单击时,模态将在新路径中打开,然后在关闭模态时,他将被重定向到上一个路径,就像 Trello 的工作方式一样。请参阅此示例:trello.com/b/ezWgKsol/sales-enterprise-feature-requests-sample。点击任何一张卡片。
  • 在我的情况下打开模式不会打开新路线。听起来在您的用例中您需要访问不同的模型,因此需要打开新路线?
猜你喜欢
  • 1970-01-01
  • 2014-01-28
  • 1970-01-01
  • 2012-07-19
  • 1970-01-01
  • 2013-08-18
  • 2013-12-29
相关资源
最近更新 更多