Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clone tool-tip element? #74

Closed
7 tasks
ghost opened this issue May 29, 2016 · 2 comments
Closed
7 tasks

How to clone tool-tip element? #74

ghost opened this issue May 29, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented May 29, 2016

I'd like to clone div including tool-tip to other element.
See live demo.
I'd expect that cloned element also has tooltip (but it doesn't).

Live Demo

http://jsbin.com/vololicezu/1/edit?html,output

Browsers Affected

  • [ x] Chrome
  • Firefox ?
  • Safari 9 ?
  • Safari 8 ?
  • Safari 7 ?
  • Edge ?
  • IE 11 ?
  • IE 10 ?
@notwaldorf
Copy link
Contributor

The cloning part works fine -- if you look at the resulting DOM, the tooltip is in the right place:
screen shot 2016-05-31 at 10 43 45 am

The problem is that because you did a literal clone, and the tooltip targets a specific element (for="id_1"):, your cloned tooltip still targets the first span, so you'll have to update the IDs with something like:

var newPlace = document.querySelector('#new-place');
newPlace.querySelector('span').id = 'id_2';
newPlace.querySelector('paper-tooltip').for = 'id_2';

Here's your jsbin, updated with this code: http://jsbin.com/sitawo/edit?html,output

@ghost
Copy link
Author

ghost commented May 31, 2016

Thanks for clarification. :)
Of course tooltip can be used without ids, like documentation says
https://elements.polymer-project.org/elements/paper-tooltip?view=demo:demo/index.html
section:
"Tooltips can be anchored to elements relative to their parent"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant