turbolinks

Clicking “back” in the browser disables my javascript code if I'm using Turbolinks in Rails

扶醉桌前 提交于 2019-11-28 21:23:45
Well, as the title says more or less. I'm using the gem Turbolinks in my Rails application and I'm having a bit of a problem with the "browser back"-button. My javascripts works fine until i click back in my browser, then it stops working. If I click a link in my app or reload the page it starts working again. Ant ideas how to fix this? UT KU The jquery-turbolinks gem doesn't support Turbolinks 5 anymore, so that solution is deprecated right now. If you'd like to disable turbolinks-caching, just add this meta to your page; <meta name="turbolinks-cache-control" content="no-cache"> Two solutions

JQuery in Rails is failing after linking from another page, works on page load

笑着哭i 提交于 2019-11-28 12:51:02
I have a quote rotator I use on my homepage. When I load the page from the browser directly (type the address in the browser and hit enter) it works fine.. However, if I click on a link to another page in my site and then link back to home it stops working. More specifically, it the quotes start to overlap almost as if two instances of the method are running. I think it may be a problem with how the javascript is loading. Since I have a tab script on another page in the site and it will load fine, but if I link away and back to the page it no longer works... Receiving no errors in the console.

javascript_include_tag throws unsupported method

China☆狼群 提交于 2019-11-28 12:33:57
I recently created a new project with Rails 4.2.0 and created a controller called Land for the landing page. So, I ran into this error upon visting http://localhost:3000/land/home : Started GET "/" for ::1 at 2015-02-27 15:56:23 -0600 Processing by LandController#home as HTML Rendered land/home.html.erb within layouts/application (0.0ms) Completed 500 Internal Server Error in 5526ms ActionView::Template::Error (TypeError: Object doesn't support this property or method (in C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)): 3: <head> 4: <title

Rails 4 Turbolinks make form submit multiple times

ぃ、小莉子 提交于 2019-11-28 10:22:43
I use some code working nicely on Rails 3 but not on Rails 4, I guess it is caused by Turbolinks but I don't know much about it, can't dig more deep to solve my problem, here is the code: view: a/v/m/_new_comment.slim .new-comment - if current_user = render "editor_toolbar" = form_for(Comment.new, :remote => true, :url => mission_comments_path(@mission)) do |f| = f.text_area :content, :class => "span10", :rows => "4", :tabindex => "1" #preview.hidden = "Loading..." = f.submit t("missions.submit_comment"), "data-disable-with" => t("missions.submitting"), :class => "btn btn-primary", :tabindex =

Rails 4 turbolinks with Google Analytics

你。 提交于 2019-11-28 03:59:23
I'm wondering what is the best way to implement Google Analytics tracking code along with the turbo linking in Rails 4. Will the normal snippet work? I've also seen a gems for this but I'm not sure what it does. vladCovaliov I think a better idea is to use the new Universal Analytics (from analytics.js file). Universal Analytics Solution (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,

Turbolinks load event not working on with page refresh

三世轮回 提交于 2019-11-28 03:34:57
问题 Javascript code like this document.addEventListener("turbolinks:load", function() { $("p#hide_if_js").hide(); }); is working fine with turbolinks when I click between pages or use the browser back button. However, when I refresh the page, the javascript code is not loaded. If I refresh a few times, nothing happens, but if I click a link to a different back and click back to the page, the javascript code is now loaded. It looks like the turbolinks:load is working on most events, but not the

Rails 4: disable Turbolinks in a specific page

£可爱£侵袭症+ 提交于 2019-11-27 17:42:02
I'm trying to make a JS snippet work in a concrete page with Rails 4 and Turbolinks. I've tried with the standard solution: <script type="text/javascript"> var ready = function() { // Bla bla }; $(document).ready(ready); $(document).on('page:load', ready); </script> But it doesn't seem to work. My snippet is something like this: <script type="text/javascript"> function ismready() { var API_KEY = "api key"; var roomId = "room id"; var ism = new Ismuser(API_KEY, roomId); ism.init({ board: { layer: "board" }, video: { camsContainer: "guest" }, chat: { layer: "chat" }, moderator: true, }); } <

Re-rendering specific js file with turbolinks enabled

巧了我就是萌 提交于 2019-11-27 15:20:03
问题 I'm working with Rails 4 and would like to use the built in Turbolink gem. I'm happy with all it does except I'd like it to reload one of the js files upon every page request. In other words I'd like a specific js file to ignore turbolinks, how can I do this? 回答1: You can use 'page:load' event from turbolinks to connect an initialize function to it. It will be called always when turbolinks fully reaload your new page. function initialize() { //js code what you want run always } $(document)

Clicking “back” in the browser disables my javascript code if I'm using Turbolinks in Rails

余生长醉 提交于 2019-11-27 13:49:15
问题 Well, as the title says more or less. I'm using the gem Turbolinks in my Rails application and I'm having a bit of a problem with the "browser back"-button. My javascripts works fine until i click back in my browser, then it stops working. If I click a link in my app or reload the page it starts working again. Ant ideas how to fix this? 回答1: The jquery-turbolinks gem doesn't support Turbolinks 5 anymore, so that solution is deprecated right now. If you'd like to disable turbolinks-caching,

JQuery in Rails is failing after linking from another page, works on page load

心不动则不痛 提交于 2019-11-27 07:23:42
问题 I have a quote rotator I use on my homepage. When I load the page from the browser directly (type the address in the browser and hit enter) it works fine.. However, if I click on a link to another page in my site and then link back to home it stops working. More specifically, it the quotes start to overlap almost as if two instances of the method are running. I think it may be a problem with how the javascript is loading. Since I have a tab script on another page in the site and it will load