Détail du package

ember-tether

yapplabs65kMIT3.1.0

Tether an element to another element in the DOM

ember-addon, tether

readme

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.

Compatibility

  • Ember.js v3.28 or above
  • Ember CLI v3.28 or above
  • Node.js v14 or above

For Ember 1.13 - 2.3, use 0.4.1. For support for earlier versions of Ember, use ember-tether 0.3.1.

Installation

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:

<EmberTether
  @target='#a-nice-person'
  @targetAttachment='top right'
  @attachment='top left'
>
  A puppy
</EmberTether>

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 this.isShowing}}
  <EmberTether
    @target='#a-nice-person'
    @targetAttachment='top right'
    @attachment='top left'
  >
    A puppy
  </EmberTether>
{{/if}}

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

Similarly, if you use <EmberTether /> 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

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 0.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.

Contributing

See the Contributing guide for details.

License

  • Ship Shape 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

changelog

Change Log

v3.1.0 (2024-03-12)

:rocket: Enhancement

  • #129 Update to Ember v5.4 with ember-cli-update (@mansona)

:house: Internal

Committers: 2

v3.0.0 (2023-05-05)

:boom: Breaking Change

If you are passing @class=... to ember-tether, this will no longer work. Pass class=... instead.

:rocket: Enhancement

Committers: 1

v2.0.1 (2021-09-09)

:house: Internal

Committers: 3

v2.0.0 (2020-04-15)

:boom: Breaking Change

:memo: Documentation

:house: Internal

Committers: 3

1.0.0 (2018-06-10)

Full Changelog

Merged pull requests:

v1.0.0-beta.3 (2018-05-23)

Full Changelog

Merged pull requests:

v1.0.0-beta.1 (2018-02-09)

Full Changelog

Merged pull requests:

  • upgrades ember-cli-babel (and other packages) #46 (NLincoln)

v1.0.0-beta.0 (2017-04-11)

Full Changelog

Merged pull requests:

v0.4.1 (2017-02-03)

Full Changelog

Merged pull requests:

v0.4.0 (2017-01-01)

Full Changelog

Merged pull requests:

  • Update ember-cli, tether, and ember versions, and introduce bodyElementId option #39 (lukemelia)

v0.3.1 (2016-05-11)

Full Changelog

Merged pull requests:

v0.3.0 (2016-03-02)

Full Changelog

Merged pull requests:

v0.2.1 (2016-01-22)

Full Changelog

Merged pull requests:

v0.2.0 (2015-11-02)

Full Changelog

Merged pull requests:

v0.1.3 (2015-06-18)

Full Changelog

Merged pull requests:

  • Update ember-try config to test 1.12 and 1.13. #5 (rwjblue)
  • Remove instanceof Ember.View check. #4 (rwjblue)

v0.1.2 (2015-06-09)

Full Changelog

Merged pull requests:

v0.1.1 (2015-05-19)

Full Changelog

Merged pull requests:

v0.1.0 (2015-05-18)

* This Change Log was automatically generated by github_changelog_generator