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

Please clearify «targets» #32

Open
chmich opened this issue Apr 25, 2023 · 1 comment
Open

Please clearify «targets» #32

chmich opened this issue Apr 25, 2023 · 1 comment

Comments

@chmich
Copy link

chmich commented Apr 25, 2023

Hi,

Many of your functions have the first attribute: targets.

I made a test on turbo_frame_set_src and noticed that its interpreting a simple string as id, because: #cars-box does not work while cars-box successfully targets the element with the id cars-box.

So under targets I would expect that a value like .cars-box would affect all matching elements as it would be the case with jquery.

Could you please clarify this?

On my gem, which includes yours in many cases, I kept the same naming because I thought target was a good naming for what it means, but clarified that target has a value like #my-target in logs, for example.

And why not allow css matchers like .customer-wrapper > #form? Yes, html-id should be unique, but this is hard to control and for complex pages child selectors would be a help.

Thanks,
Chris

@Timmitry
Copy link

Timmitry commented Nov 10, 2023

I want to add to this that I was also quite confused. Turbo-Rails always supports two possible variants:

turbo_stream.replace("myid") # Will target a single node with id="myid"
turbo_stream.replace_all("#myid") # Will target all nodes with id="myid" (still only one as IDs need to be unique)

Note the usage of # in the second example, but not in the first example.

So, when using turbo_stream.morph, I thought that I had to use "myid" as target, but actually needed to specify "#myid", which is confusing.

Anyway, thanks for your efforts, I now have the morphing working like a charm 😊

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

2 participants