turbolinks

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

依然范特西╮ 提交于 2019-12-04 09:58:35
I have a very simple link on my page. <a href="#">My link</a> . 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

Is it possible to disable Turbolinks for specific jQuery Ajax calls to prevent the page from refreshing and scrolling?

爱⌒轻易说出口 提交于 2019-12-04 06:41:01
I have a Rails 5 application and would very much like to use Turbolinks. Within the application there are several PATCH ajax calls that simply update the server with new data, but do not need to worry about updating the state of the page. Whenever these ajax requests return, Turbolinks refreshes the page and the browser scrolls to the top of the screen. This is not desirable behavior; it is much preferred that things just stay put where they are. Disabling Turbolinks eliminates the problem. Example (super basic) ajax call that causes the problem: $.ajax({ method: "PATCH", url: url, data: obj }

How to refresh a page with Turbolinks

微笑、不失礼 提交于 2019-12-04 03:00:04
I understand that I can call the following code on Turbolinks 5 but it changes the scroll position. Is there a way to call Turbolinks to refresh the page and not change the scroll position? Turbolinks.visit(location.toString()); This will do what I want, but was hoping to use Turbolinks window.location.reload() Store the current scroll position before calling visit , then when the page loads, scroll to that stored position. Resetting the stored scroll position to null ensures that subsequent page loads will not scroll to an old position. One possible implementation might be: var

Prevent Google maps JS executing multiple times caused by Rails Turbolinks

扶醉桌前 提交于 2019-12-04 01:35:23
I'm currently working on Rails app that is getting the following error: You have included the Google Maps API multiple times on this page. This may cause unexpected errors. After a little research I discovered that Turbolinks was causing the problem. When the link_to is clicked all of the DOM elements created by Google maps are retained within the DOM. When a new page is rendered another set of Google Map DOM elements is added causing duplicates and the error. I could fix this very quickly by simply adding 'data-no-turbolink' => true to my link_to but this defeats the purpose of using

Bootstrap 3 dropdown doesn't work with Rails 4 & Turbolinks

夙愿已清 提交于 2019-12-03 18:07:59
问题 I recently upgraded my site to Bootstrap 3 and am in the process of going through all the layouts to update class names and various functionality to work correctly. My most recent problem is that drop downs don't seem to be working. At first I thought I hadn't implemented the code correctly for my nav bar, but after getting frustrated, I actually tried just getting rid of my nav bar and using the one straight out of the BS 3 documentation. Even that code doesn't work. I've looked into this,

Datepicker does not display the calendar

烂漫一生 提交于 2019-12-03 17:36:47
问题 I have in my application a form where I can chose a date from a datepicker calendar. When I refresh my page, the datepicker calendar appears when clicking the form. This is the correct behaviour. However when I reach the same page from another page using a link, the calendar does not appear after clicking the form. I have to refresh the page in order to make the calendar visible. Here is my form page: # app/views/reservations/_form.html.erb ... <div class="row reservations"> <div class="span2

Turbolinks with carrierwave images as CSS background-image

风流意气都作罢 提交于 2019-12-03 11:11:50
I've been using turbolinks along this year but lately I'm getting this annoying bug. Images uploaded via carrierwave are loaded in the site with absolute URL's in the first request, but when you start browsing in the site via turbolinks, all carrierwave images change to relative paths. <%= image_tag "image.jpg %> elements work ok, but the images are loaded as CSS background-image, they don't appear. This apparently happens only on chrome (I have Versión 31.0.1650.57 m). I made a trace via console and all images are loaded in the document, so I went to the Inspector and disabled/enabled the

How to disable Turbolinks in a specific page?

孤街醉人 提交于 2019-12-03 10:55:56
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 the "data-no-turbolink" attribute directly to the body tag in application.html.erb it works. How do I disable Turbolinks in my view? I have followed the solution posted here, Rails 4: disable Turbolinks in a specific page but I can't get it to work. I have the gem 'jquery-turbolinks' installed. policy.html.erb <% content_for :body do %> <% if controller.controller_name == 'pages' && controller.action_name == 'policy' %>

Turbolinks 5.0 and Facebook SDK

心不动则不痛 提交于 2019-12-03 09:01:42
Last week I upgraded to Rails 5 which is using Turbolinks 5.0. I used the following script to load the Facebook like button with Turbolinks 3.0: fb_root = null fb_events_bound = false $ -> loadFacebookSDK() bindFacebookEvents() unless fb_events_bound bindFacebookEvents = -> $(document) .on('page:fetch', saveFacebookRoot) .on('page:change', restoreFacebookRoot) .on('page:load', -> FB?.XFBML.parse() ) fb_events_bound = true saveFacebookRoot = -> fb_root = $('#fb-root').detach() restoreFacebookRoot = -> if $('#fb-root').length > 0 $('#fb-root').replaceWith fb_root else $('body').append fb_root

Rails 4 and Turbolinks - Meta Tags not changing

陌路散爱 提交于 2019-12-03 07:26:43
问题 I have a Rails 4 app with turbo-links enabled, but I can't get the meta tags to refresh when changing the page ( not a full refresh ) . I read that the meta-tags need to be included before the javascript that loads the turbo-links but it has no effect. A full refresh does the job, but unfortunately this is not what i search for. layout/application.html.haml %html %head %title= "Title" - if content_for?(:meta_description) %meta{content: (yield :meta_description), name: "description"}/ %meta