turbolinks

using jQuery's delegated event on() within every turbolinks page:load

╄→尐↘猪︶ㄣ 提交于 2019-12-08 13:19:29
I had this code in my rails app: $(document).ready( function() { myCustomFunction("#link-selector"); } function myCustomFunction(linkCssSelector){ // some stuff... $(document).on('click', linkCssSelector, function(){ // ...some other stuff... }); } The click event handling is already delegated to the document , but now I have to add Turbolinks to my app. Then, I would take of the ready() function and do the following (based on my searches): $(document).on("ready page:load", function() { myCustomFunction("#link-selector"); } But some references tell me not to add bindings inside the page load,

Javascript DOM events before and after Turbolinks cache

☆樱花仙子☆ 提交于 2019-12-08 08:53:57
问题 Here I have: $(document).on 'turbolinks:load', -> console.log "page has loaded!" $ -> $("button#show-hide").click (e) -> e.preventDefault() which makes my click event available only after Turbolinks caches page. I can do $(document).on 'turbolinks:before-visit which will make event available only before Turbolinks caches. How should I make event available at all times? 回答1: I think the problem here is that you are binding to two events: turbolinks:load and $(document).ready() . Turbolinks

how to make add this work with turbilinks rails 4

故事扮演 提交于 2019-12-08 08:49:09
问题 I have been working on this for almost a day now and cant figure out how to make addthis work wtih turbolinks and rails 4. my add this code is <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script> <script type="text/javascript"> addthis.layers({ 'theme' : 'transparent', 'share' : { 'position' : 'left', 'numPreferredServices' : 6 }, 'follow' : { 'services' : [ {'service': 'facebook', 'id': 'blanckdigital'}, {'service': 'twitter', 'id': 'blanckdigital'} ] },

Javascript not showing up in Rails 4. (Highchart)

限于喜欢 提交于 2019-12-08 06:53:04
问题 I've included Highcharts in a simpler Rails Application and it works just fine. but when I did the same thing in a more complex Rails Application the Javascript code the Chart is not showing up. here's what I did so far: Gemfile gem "highcharts-rails", "~> 3.0.0" application.js //= require highcharts //= require highcharts/highcharts-more show.html.erb <div class="panel panel-default"> <div class="panel-heading">Chart</div> <div id="container" style="width:100%; height:400px;"> </div> <script

TurboLinks with Angular

本小妞迷上赌 提交于 2019-12-08 06:26:21
问题 I'm running Angular 1.6 along with TurboLinks 5. For the most part, things are working well. I disabled TurboLinks cache and am manually bootstrapping Angular per some of the suggestions on this post: Using angularjs with turbolinks I have run into one issue though where I have an $interval running within a service. When changing pages via TurboLinks, Angular bootstraps again and the service creates a new interval, but the old one continues to run! Every time a page change event occurs, a new

Form with remote: true not working with turbolinks

给你一囗甜甜゛ 提交于 2019-12-08 05:26:46
问题 I have setup a form and set remote: true on it. While it works if i directly refresh the page. IF i navigate from menu to the desired form the button just does nothing. I tried adding "data-no-turbolink="true" to the link of menu but still it doesn't work maybe because of turbolinks 5 not sure? <%= form_for :location, url: get_inventory_path, remote: true do |f| %> <div class="input-field col s12"> <%= f.select :location_id, options_for_select(@locations.collect { |l| [l.station + ', ' + l

Google Tag Manager Preview does not display when navigating to pages with TurboLinks

醉酒当歌 提交于 2019-12-08 05:17:19
问题 I don't think GTM is recording data correctly for my Rails app. When i use the preview feature, the GTM preview data in developer tools only shows on initial page loads, subsequent page loads (using turbolinks) do not show the preview data. How should I set up GTM with TurboLinks? I have set up my GTM in the header like this: <script> var dataLayer = []; (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d

How to enable `sorttable.js` on Rails4 with turbolinks

烂漫一生 提交于 2019-12-08 03:50:47
问题 Rails 4.2.0, turbolinks (2.5.3) jquery-rails (4.0.3), jquery-ui-rails (5.0.3) sorttable.js App used on Chrome, Firefox, and IE WHAT SHOULD HAPPEN : Whether a redirect, render, or just clicking to a new page in the app, any table with class sorttable (I edited it in the original JS) should be sortable by column heading. WHAT ACTUALLY HAPPENS : I am on a contacts page. I hit refresh, and logger statements in the JS appear. The plugin works as expected. If I navigate to Home, then back to

Turbolinks wipes out jQuery Mobile classes

若如初见. 提交于 2019-12-08 00:25:44
问题 When I load a page in my rails app using Turbolinks, the DOM lacks the styles that are normally applied by jQuery Mobile. All of my JavaScript files run; the only problem is that I lose some of the styles I need for the JavaScript to actually work. For example, with Turbolinks, my header is: <a rel="external" href="/">MY SITE</a> Without, it is: <a rel="external" href="/" class="ui-link">MY SITE</a> I have confirmed that my JS files are running with Turbolinks. The trouble is that the

facebook comments plugin showing only after refresh

倖福魔咒の 提交于 2019-12-07 19:30:04
问题 I am trying to use the facebook comments plugin. I have this code, I have added after the opening <body> tag and also tried before de closing </body> like suggested here <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=MY_APP_ID&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook