Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Use dynamic target - How to? #105

Closed
ei02028 opened this issue Jul 3, 2014 · 5 comments
Closed

Use dynamic target - How to? #105

ei02028 opened this issue Jul 3, 2014 · 5 comments
Labels

Comments

@ei02028
Copy link

ei02028 commented Jul 3, 2014

Hi guys,

I'm a completely newbie on github and I wasn't able to find help for my problem/doubt. For that, I apologize.

I'm trying to set the target dynamically because I don't have the final id of the element. For that purpose, I'm using "document.querySelector". But isn't working.

Here is my hopscotch code (forget the portuguese):

var tour = {
id: "AdminChangePasswordAndUsername",
steps: [
{
target: document.querySelector('.admintutorialstep1'),
placement: "left",
title: "1",
content: "1"
},
{
target: document.querySelector('.admintutorialstep2'),
placement: "left",
title: "Seleccione a área de administradores",
content: "Clique no botão da área de administradores"
},
{
target: document.querySelector('.admintutorialstep3'),
placement: "left",
title: "Envie as credenciais",
content: "Clique no link enviar credenciais e, de seguida, confirme o envio das mesmas"
}
]
};

hopscotch.startTour(tour);

If I run the code on chrome, the query selector is able to return something like this:

"

"

Which means that it should work but it doesn't :)

Can anybody help me? Thanks

@k10world
Copy link
Contributor

k10world commented Jul 3, 2014

Did you try target: 'div.admintutorialstep1' without the document.querySelector? That should work. Assuming there is only one div with that class else, it will point to the first or last.

@ei02028
Copy link
Author

ei02028 commented Jul 3, 2014

Perfect! Thanks :)

Maybe this kind of things should be on the documentation or examples.

@gthomas3
Copy link

gthomas3 commented Jul 7, 2014

Agreed. Documentation of this would be helpful. I'm using hopscotch with Knockout JS where all data is dynamic, and this technique is needed in order to successfully target the dynamically created divs

@kate2753 kate2753 added the docs label Dec 2, 2014
@rsanchez-RA
Copy link

I agree that this should be part of the documentation. Was struggling with this same issue for some time. Thanks @k10world

@k10world
Copy link
Contributor

my pleasure :-)

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

No branches or pull requests

6 participants