Turbolinks 5 not changing url in browser for already visited pages - ruby-on-rails

Using turbolinks in my application with rails 4. Basically facing an issue due to turbolinks that when I click on any link_to which already visited , the request goes to server and content of whole page changes but url in browser remains same.
After this on any link I click content changes but browser url remains same. I check by removing turbolinks and then this issue not appears. How can I fix it?

Try with this solution it might help you
<%= link_to "Policy", policy_path, :"data-no-turbolink" => true %>

Related

Implementing SitePoint's Infinite Scolling in rails by Ilya Bodrov-Krukowski

I am implementing, http://www.sitepoint.com/infinite-scrolling-rails-basics/, into my own project.
It works when I type URL directly to browser after I have implemented it in my own project. However, it does not work if I link_to from a different page. It goes back to regular will_paginate, then I hit "reload" button on browser, it starts tp work again.
However, I don't want my users to hit "reload" button every time for making infinite scrolling to work. What might cause this and how can I fix it? Thanks a lot!
It is caused by turbolinks
However, it is not a fix by installing jquery-turbolinks.
After reading turbolinks documents, temporarily disable turbolink for that particular link with
Home (via Turbolinks)
<div id="some-div" data-no-turbolink>
Home (without Turbolinks)
</div>

Bxslider only works when refreshing the page

Why does bxslider not loading in the beginning but works when I refresh the page?
I already begin with $(document).ready(function(){});
I'm building it on Rails FYI.
https://photos4humanity.herokuapp.com/galleries
If you click on gallery, you will see a black page, then if you refresh it appears. Also it is not showing when I just click onto the link from the nav bar.
It should look like this
Ok, so after some troubleshooting, it's a rails specific situation. Turbolink that came with Rails prevented the site to reload. So download the jquery-turbolink gem will work.
JQuery gets loaded only on page refresh in Rails 4 application

Why does my form widget render on every request EXCEPT for the first request?

I have a problem with a recaptcha widget that I am trying to render on my new.html.haml file. When I click on a link to take me to
localhost:3000/forums/:id/topics/new
I am met with a form that I've created on the new.html.haml page with all the fields detailed except for a recaptcha widget, which I need rendered.
When I refresh the new.html.haml page the recaptcha widget is rendered including all subsequent requests and I am able to see the widget on the web page. Why does this happen? I've never encountered an error like this before and I don't even know where to start looking. In my development.log file, I notice that when I send the first GET request to new.html.haml I see that no GET request is made to any assets in my rails app. Here is a picture below illustrating my point:
When I click the refresh page, I have the exact same output as the picture below with the exception that a series of GET requests will start to grap everything in my assets folder. On the refresh request, I will see a series of lines like the one below:
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2015-01-22 12:45:11 -0500
I'm assuming that this is the problem, but where do I go from here? I've read about the asset pipeline but I didn't find anything that seemed relevant to this problem. Is this a caching problem? What other avenue can I explore to narrow this down? Any suggestions would be helpful. Thanks.
Thanks to BroiSatse, I discovered that the problem was indeed turbolinks. To solve the problem all I needed to do was to extract the new_path from turbolinks like so:
Home (via Turbolinks)
<div id="some-div" data-no-turbolink>
Home (without Turbolinks)
</div>
More information can be found on the turbolinks github page: Turbolinks docs

Turbolinks causes a link with href="#" to trigger page refresh

I have a very simple link on my page. My link. It causes a page refresh. when I remove "turbolinks", it no longer causes a refresh.
I've used links with hash fragments all the time in the past. Unless I've missed something very fundamental for a long time, I don't understand how this can cause a refresh.
It does not have any JS event handlers attached to it.
Any ideas?
It may not matter, but I'm using jQuery, Twitter-Bootstrap, and Ruby on Rails.
Clues so far:
When I remove Turbolinks, the link behaves properly (does not cause page refresh).
Links with "#" as the URL cause a reload on every page of my app.
Links with any "#hasfragmenttext" will cause a single refresh and then the URL of the page is "mypage#hasfragmenttext", any additional clicks do NOT cause page refresh... hmm.
The above solution didn't work for me but this did :
My link
This can be found at https://github.com/turbolinks/turbolinks
update: This solution works for turbolinks 5, for classic turbolinks check the previous answer by #wael34218
Use data-no-turbolink attribute on that link the error should be gone
<a href="#" data-no-turbolink>My link</a>
With Rails 7 / Hotwire, you now need to use:
data-turbo="false"

Wrong layout used on first load after switching to/from mobile version of application

I have 2 application layouts: application.html.haml and application.mobile.haml. But when I switch from mobile to the non-mobile version the mobile layout is still used for the first load. In Firebug console I see that the non-mobile view was properly returned, however the browser and the Firebug HTML tab show the mobile layout. Any idea what's going? It's fine after a refresh.
The issue turned out to be caused by JQuery Mobile.
I found the answer here: http://jquerymobile.com/demos/1.0a3/docs/pages/docs-pages.html
JQuery Mobile doesn't do full page reloads unless it's told to, so although the full html was returned, JQuery Mobile just replaced the page portion.
The key portion from the docs is:
"It's important to note if you are linking from a mobile page that was loaded via Ajax to a page with multiple internal pages, you need to add a rel="external" or data-ajax="false" to the link. This tells the framework to do a full page reload to clear out the Ajax hash in the URL. This is critical because Ajax pages use the hash (#) to track the Ajax history, while multiple internal pages use the hash to indicate internal pages so there will be a conflicts."
Recently, I encountered a similar problem.
In my case, Rails4's turbolinks suffered. Similarly as JQuery Mobile, turbolinks only updates the body part of a full page without updating the head part of the html when an intra-site link is clicked. I simply removed the require line for turbolinks in my application.js and the problem disappeared.

Resources