Tether an element to another element in the DOM
JavaScript HTML CSS
Latest commit f99b20c Dec 31, 2016 @lukemelia lukemelia Released v0.4.0
Permalink
Failed to load latest commit information.
addon Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
app Create ember-tether addon May 18, 2015
config Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
tests Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
vendor Create ember-tether addon May 18, 2015
.bowerrc Create ember-tether addon May 18, 2015
.editorconfig Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
.ember-cli Create ember-tether addon May 18, 2015
.eslintrc.js Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
.gitignore Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
.jscsrc Add ember-suave for jscs Nov 1, 2015
.npmignore Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
.travis.yml Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
.watchmanconfig Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
CHANGELOG.md Released v0.4.0 Jan 1, 2017
LICENSE.md Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
README.md Released v0.4.0 Jan 1, 2017
bower.json Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
ember-cli-build.js Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
index.js Pull tether from npm instead of Bower Feb 26, 2016
package.json Released v0.4.0 Jan 1, 2017
testem.js Update ember-cli, tether, and ember versions, and introduce bodyEleme… Jan 1, 2017
testem.json Create ember-tether addon May 18, 2015

README.md

Ember Tether Build Status Ember Observer Score

This ember-cli addon provides a component that allows for 'tethering' a block to a target somewhere else on the page. The target may be an element, an element selector, or an Ember view. Importantly, the component retains typical context for Ember action handling and data binding.

ember-tether is currently tested in Ember 2.4 and higher. For support for earlier versions of Ember, use ember-tether 0.3.1.

Live Demo

View a live demo here: http://yapplabs.github.io/ember-tether/

Installation

ember install ember-tether

Note: Ember CLI versions < 0.2.3 should use ember install:addon instead of ember install

Example Usage

Given the following DOM:

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

and a template like this:

{{#ember-tether
    target='#a-nice-person'
    targetAttachment='top right'
    attachment='top left'
}}
  A puppy
{{/ember-tether}}

Then "A puppy" would be rendered alongside the a-nice-person div.

If the ember-tether component is destroyed, its far-off content is destroyed too. For example, given:

{{#if isShowing}}
  {{#ember-tether
      target='#a-nice-person'
      targetAttachment='top right'
      attachment='top left'
  }}
    A puppy
  {{/ember-tether}}
{{/if}}

If isShowing starts off true and becomes false, then the "A puppy" text will be removed from the page.

Similarly, if you use ember-tether in a route's template, it will render its content next to the target element when the route is entered and remove it when the route is exited.

Acceptance Testing

Hubspot Tether works by appending tethered elements to the <body> tag. Unfortunately, this moves your content outside of the Ember application rootElement during acceptance testing. This breaks event dispatch and action handling, including traditional Ember test helpers like click.

As of version 1.4.0, we can configure a different element to be used instead of body. This can be useful for Ember tests.

// config/environment.js

ENV['ember-tether'] = {
  bodyElementId: 'ember-testing'
};

It is also possible to pass a bodyElement to a particular ember-tether component declaration.

Development Setup

Installation

  • git clone this repository
  • npm install
  • bower install

Running Tests

  • ember test
  • ember test --serve

This addon uses ember-try to test against multiple versions of Ember:

  • ember try:each
  • ember try:one ember-release --- ember test --serve

Running the dummy app

  • ember server
  • Visit your app at http://localhost:4200.

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

Generating the Changelog

This project uses https://github.com/skywinder/github-changelog-generator to generate its changelog.

Credits

  • Hubspot Tether, the underlying library that implement the actual tethering behavior
  • ember-wormhole, whose pattern for element content manipulation inspired the approach in ember-tether
  • Tetherball, for providing countless hours of entertainment over the past century