The documentation for this gem says that it is necessary in order to get a new page from the server via ajax, parse it on the client side and replace only the contents of the body and head tags.

The standard "one-page" application that receives pages from the server via ajax I always checked with the following, as it seems to me, reliable method: I inserted a tag onto one page (in the case of rails this is audio_tag) and a link to another page. If, when switching to another page via this link, the music that started playing on the previous page continued to play, it means that ajax really works as it should and the page doesn’t do its usual reloading cycle, but is parsed directly from the server from the html client.

But in gem turbolinks, the application installed by default in rails, I see that everything is different.

I misunderstand the essence of his work? And doing something wrong?

  • Heh. Heh. Hehe. Heh heh heh heh heh. And <audio> where, in <body> ? - D-side
  • @ D-side Yeah, why? Well, at least it would be illogical to put it in the head. - smellyshovel
  • Well, I was under the impression that the whole body is being replaced and everything that was in it stops / dies. But in general, in appearance, according to speculation, it is not. Attach the executable example, the browser used and the Turbolinks version. - D-side
  • So that? Details will be? - D-side
  • @ D-side How to tell you. My head is spinning memories of how calmly organized the transition through the pages with the help of Ajax and the music continued to play. I tried it now - it does not work. How I did it then - I do not understand. Therefore, the example does not see the point spread. Apparently, this behavior is justified, because, replacing the whole body tag, the audio tag is also replaced (respectively, the old tag disappears and the music stops). Of course, this has its advantages (page loading speed), but if you need to implement your mechanism, you will have to put the whole turboLinks on crutches. - smellyshovel

1 answer 1

Turbolinks Ajaksovo gets html -an answer from the server and replaces the whole body Information inside the head not replaced. It is also possible to mark any tag in the body as permanent, and it will not be replaced. In the fifth version of turbolinks, this is flagged via the data-turbolinks-permanent attribute.

  • Accidentally I got this question today, did not immediately notice that you gave the answer. Thank you, I hope, still useful. - smellyshovel