Can I manually navigate with turbolinks in Rails?
Asked Answered
A

1

8

I have an html table with rows and a jQuery handler on click.
The click event calls window.location.href which causes a full page refresh.

Can I somehow manually call turbolinks to fetch the page? Should I use PJAX instead?

Thanks

Antananarivo answered 14/4, 2014 at 18:19 Comment(0)
A
22

From the Turbolinks Readme:

You can use Turbolinks.visit(path) to go to a URL through Turbolinks.

Ayeaye answered 14/4, 2014 at 18:25 Comment(13)
@DaveNewton As long as those docs are up to date; yup, it's easy.Ayeaye
if by docs you mean google search not finding this link then sure ;)Antananarivo
You're welcome. Although I'm always stunned by the number of questions that are easy to answer by just reading/searching the Guides, API Docs and the Ruby API Docs. But in your favour, that link to the Turbolinks readme was actually a little hidden in there somewhere.Ayeaye
This is a case of having to deal with Turbolinks breaking page loads, 3rd party plugins, and promoting poor patterns (head loading scripts). After dealing with all that, and then not having the most straightforward result in google I turned to here for a quick fix. That doesn't mean I need 2 people harping on how easy it was to find. I appreciate the help, but if it's an issue next just don't answer or comment, it's that easy.Antananarivo
@Antananarivo I'm sorry you feel that way. I was not trying to make you look stupid. It was just that I thought my previous comment might add something to this question/answer. And yes, using turbolinks very soon turns out to be a PITA.Ayeaye
@Antananarivo It's on the homepage of the library; don't even really need to google for it--just check the repo of the library. You may think it's "harping", I think it's "due diligence".Lesleylesli
First, the goal of SO is to be a canonical source of information for software development. SO didn't match find a match to my question so it's a valid question. Second, if google didn't match the query there is an issue. Adding it here and linking to the documentation with the verbiage on this page will increase the pagerank so other's can quickly find the answer. As for "due dilligence", @dave your comments in this thread have not contributed to answering the question.Antananarivo
@Antananarivo The idea that SO should be a replacement for reading documentation, of the library you're using, is laughable, but not funny. The documentation is the canonical source, and it should have been the first place you looked, and essentially zero search skills are needed to find it. I don't even understand the mindset that doesn't believe reading the docs or the code shouldn't be the canonical choice- it is, after ask, the reality of your code base. Good luck.Lesleylesli
@Dave you should listen to Joel and Jeff talk about the purpose of this site then, try the podcasts.Antananarivo
@blue So should you. Ignoring the docs, which are the place to look for library documentation, is willfully neglectful and lazy. It takes zero effort to find the docs for a library you know you're using. It's pathetic and sad, and the mark of a developer who is either unwilling or unable to thrive in their environment. It's on the homepage of the library docs, in bold letters-it will rarely be any easier than that. Good grief. Even wise is that you keep defending ignoring the docs like you're helping the "community" by not bothering to read them.Lesleylesli
@DaveNewton "It's pathetic and sad, and the mark of a developer who is either unwilling or unable to thrive in their environment." Is... is this a joke. You're kidding me right? Also, this is question is now #2 on google with the answer (and your rantings) immediately available. You can stop answering now.Antananarivo
@Antananarivo Project docs should always be the first place to look, for a variety of reasons. You can stop telling people what to do now. And consider reading the docs for the stuff you're using. There's a reason you had two people "harping" on not reading the docs, although the original comments don't fall under that definition.Lesleylesli
This is working with Rails 5.0.0 and turbolinks 5.0.0Measure

© 2022 - 2024 — McMap. All rights reserved.