The ember-routable-modal
addon allows you to quickly and easily implement URL-first modals, similar to those found on sites such as Facebook, Twitter, and Dribbble. You can navigate to modals elsewhere in the route tree without losing your place on the current page, making it ideal for lightboxes and photo viewers.
ember install ember-routable-modal
Ember.js 2.12+ is required.
You must add {{routable-modal-outlet}}
to the bottom of your application template in order for modals to render.
The addon comes with a lightweight default Sass stylesheet. To use it, you must first install ember-cli-sass, then import the files at the top of your styles/app.scss
file as so;
@import "ember-routable-modal/core";
@import "ember-routable-modal/dialog";
You can use the modal-route
generator to quickly scaffold modal routes, sharing the syntax of the built-in route
generator. Try running the following command;
ember generate modal-route example
If you are using the pod structure, make sure you pass the -p
parameter.
You will now see that a route has been generated with the provided mixin, as well as a template with a sample dialog element.
// app/routes/example.js
import Ember from 'ember';
import ModalRouteMixin from 'ember-routable-modal/mixins/route';
export default Ember.Route.extend(ModalRouteMixin, {
});
Now whenever you navigate to /example
, through the usual {{link-to}}
helper or by calling this.transitionTo()
within a route, the example
modal will render on top of your currently active route. If you load the page from the /example
URL directly, the closest parent route will be rendered underneath the modal.
You are free to delete the provided template and build your own dialog component if you wish, the addon is flexible.
Modal routes also work with the loading substate when an asynchronous object is passed to the route's model
hook. Just create a template with the filename in the format {route}-loading
, and it will be rendered on top of the modal backdrop while your model
hook waits to resolve.
You can close modals in one of two ways;
The addon comes with a service called current-routed-modal
. Simply inject it wherever you would like to be able to control the modal, for instance in a component;
import Ember from 'ember';
export default Ember.Component.extend({
modal: Ember.inject.service('current-routed-modal'),
tagName: 'button',
click() {
this.get('modal').close();
}
});
You can also use the {{routable-modal-close-button}}
component, which has the same implementation as the code sample above. You can see an example of it used in the auto-generated modal route template. It can also be used in block form, such as {{#routable-modal-close-button}}Close{{/routable-modal-close-button}}
You can override the default modal element classes by setting the ENV['ember-routable-modal']
option in config/environment.js
like so;
ENV['ember-routable-modal'] = {
modalClassNames: ['modal'],
backdropClassNames: ['modal-backdrop'],
modalOpenBodyClassName: 'modal-open'
};
Property | Default |
---|---|
modalClassNames |
['routable-modal'] |
backdropClassNames |
['routable-modal--backdrop'] |
modalOpenBodyClassName |
routable-modal--open |
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"npm test
– Runs ember try:each
to test your addon against multiple Ember versionsEmber检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查
英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客
ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv
Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena
Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb
vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo