Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-wormhole

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-wormhole

Render a child view somewhere else in the DOM.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42K
increased by5.12%
Maintainers
1
Weekly downloads
 
Created
Source

Ember Wormhole Build Status

This ember-cli addon provides a component that allows for rendering a block in a typical Ember context in terms of bound data and action handling, but attached to a DOM element somewhere else on the page.

But Why?

This library is particularly useful for cases where you have UI that is the logical child of a component but needs to render as a top-level DOM element, such as a confirmation dialog.

And How?

This component takes advantage of a private API of HTMLBars (we're hoping to craft a public API so we can be confident this library will continue to work in future versions of Ember). An Ember Component has a _morph property which its children are attached to. In a typical component, _morph is the component's element, a div by default. ember-wormhole sets the component's _morph to an element that you point it at. As a result, the component's children are attached to that element in the DOM. That includes usages of yield, so blocks provided to ember-wormhole appear in another part of the DOM. Nothing else changes -- data binding and action bubbling still flow according to the Ember component hierarchy.

Show Me Some Code!

We thought you'd never ask...

Given the following DOM:

<body class="ember-application">
  <div id="destination">
  </div>
  <div class="ember-view">
    <!-- rest of your Ember app's DOM... -->
  </div>
</body>

and a template like this:

{{#ember-wormhole to="destination"}}
  Hello world!
{{/ember-wormhole}}

Then "Hello world!" would be rendered inside the destination div.

If the ember-wormhole is destroyed it's far-off children are destroyed too. For example, given:

{{#if isWormholeEnabled}}
  {{#ember-wormhole to="destination"}}
    Hello world!
  {{/ember-wormhole}}
{{/if}}

If isWormholeEnabled starts off true and becomes false, then the "Hello world!" text will be removed from the destination div.

Similarly, if you use ember-wormhole in a route's template, it will render its children in the destination element when the route is entered and remove them when the route is exited.

Development Setup

Installation

  • git clone this repository
  • npm install
  • bower install

Running Tests

  • ember try:testall
  • ember test
  • ember test --server

Running the dummy app

For more information on using ember-cli, visit http://www.ember-cli.com/.

Credits

This addon was extracted from ember-modal-dialog. Contributions from @stefanpenner, @krisselden, @chrislopresto, @lukemelia, @raycohen and others. Yapp Labs is an Ember.js consultancy based in NYC.

Keywords

FAQs

Package last updated on 05 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc