How to disable Turbolinks in a specific page?

前端 未结 6 1648
醉酒成梦
醉酒成梦 2021-02-12 13:54

I have an issue with a script only working when refreshing the page and so I\'m trying to disable Turbolinks for only that page. The code below doesn\'t work. However, if I add

6条回答
  •  不思量自难忘°
    2021-02-12 14:32

    I tried the other methods mentioned here to no avail, but from the Turbolinks 5 docs, you can insert this meta tag on the page that you want to always load without Turbolinks.

    
    

    Adding a data attribute to all links means that you have to know where all those links are, which is brittle if you have a situation where there might be inline links in user-created content.

    The body tag data attribute method didn't work for me as I'd expect it to - I'd have assumed that loading a turbolinks-supported page and then clicking a link to go to a page where you want to disable turbolinks would result in a full, standard page load. That didn't seem to be the case, especially with back button or history navigation.

    Adding this meta tag forces Turbolinks 5 to do a full page reload before it attempts to insert any content into the dom. You get that classic flash of a blank page, but if like me, you're using external Javascript that needs to fire without interference from Turbolinks, that's the desired behaviour.

提交回复
热议问题