Giter Site home page Giter Site logo

Usage of anchor about turbo-rails HOT 5 CLOSED

kriom avatar kriom commented on August 10, 2024
Usage of anchor

from turbo-rails.

Comments (5)

kriom avatar kriom commented on August 10, 2024 1

Hi,

Both ,

I have a case where I have a direct link to a resource and I want the browser to scroll over this resource in a sidebar.
I adapt but it gives :
<a href="/conversations/7#conversation_7">conv 7</a>

  • /conversations/7 for conversation show
  • #conversation_7 to scroll to the same conversation in scrollbar

I have a case where I create a resource and via redirect I want the browser to scroll to this resource
Redirected to http://127.0.0.1:3000/conversations/7#message_50

  • /conversations/7 for conversation show
  • #message_50 to scroll to the message in the conversation

I think I need more than one anchor :D (one for my sidebar and one for my main content)

... some time later ...

OK I found a solution using
turbo_stream.scroll_into_view(targets)

Thank you !

from turbo-rails.

kriom avatar kriom commented on August 10, 2024 1

Hi @nikolaokonesh
Sorry for the long response time
With turbo_power gem installed :
When I want a link to scroll to current resource I set a scroll: true HTTP parameter to the link_to
And inside the view :

<%= turbo_stream.scroll_into_view("#" + dom_id(resource)) if params[:scroll] %>

from turbo-rails.

seanpdoyle avatar seanpdoyle commented on August 10, 2024

@kriom is the anchor part of a response's URL (like during a redirect) or are the anchors being removed from the [href] attribute of <a> elements?

from turbo-rails.

nikolaokonesh avatar nikolaokonesh commented on August 10, 2024

@kriom Tell me please, how did you do it? example

from turbo-rails.

nikolaokonesh avatar nikolaokonesh commented on August 10, 2024

@kriom Thanks!
Have you used Turbo 8?
I noticed that when updating Morph, Scroll is triggered

from turbo-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.