turbolinks

Rails turbolinks break submit remote form

半城伤御伤魂 提交于 2019-11-30 23:25:14
I'm having a rather weird problem using Rails 4, Turbolinks and a remote form. I have a form looking like: <%= form_for [object], remote: true do |f| %> <td><%= f.text_field :name, class: 'form-control' %></td> <td><%= f.email_field :email, class: 'form-control' %></td> <td><%= f.submit button_name, class: 'btn btn-sm btn-primary' %></td> <% end %> This form adds (creates) a new object. It does however not always work: When I load the page directly using the URL or a refresh; it works When I navigate from my app to this page; it fails When disabling Turbolinks for this link, the page worked

Rails 5 - turbolinks 5,some JS not loaded on page render

扶醉桌前 提交于 2019-11-29 18:02:23
问题 I have a Rails app, I recently updated to 5.0.0.RC1 . Most of the transition went smooth, but I'm having some trouble with the new Turbolinks. In my app I for example use this gem: gem 'chosen-rails' My application.js file looks like this: //= require jquery //= require jquery.turbolinks //= require jquery_ujs //= require best_in_place //= require tether //= require bootstrap //= require chosen-jquery //= require_tree . //= require turbo links When I click on a link and render a view my

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

旧巷老猫 提交于 2019-11-29 13:20:51
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, and I'm fairly certain I have all the proper .js libraries loaded. Here's my application.js: //=

Rails 4 + simple_form and jQuery UI. Datepicker is not working via turbolinks

こ雲淡風輕ζ 提交于 2019-11-29 13:05:46
问题 I have this form which calls datepicker: ... <%= f.input :expiration_date, as: :datepicker, required: false %> ... Simple_form wrapper: app/inputs/datepicker_input.rb class DatepickerInput < SimpleForm::Inputs::Base def input @builder.text_field(attribute_name, input_html_options) + \ @builder.hidden_field(attribute_name, { :class => attribute_name.to_s + "-alt"}) end end When the page is loaded from scratch ( $(document).ready event ), the following html is generated: <input class=

Googletagmanager with Turbolinks

浪子不回头ぞ 提交于 2019-11-29 11:00:05
Can someone explain how should we properly integrate Googletagmanager with Turbolinks? On normal pages we just copy/paste this code immediatelly after after the opening tag. <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-******" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(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.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm

rails 4 with turbolinks and window load

泄露秘密 提交于 2019-11-29 09:57:28
I'm using Rails 4. I'm trying to use this script to show google maps. I got a page with different places and each place got an address. It shows in google maps. So i'm using pagination and on each page I got 4 places. 4 scripts of gmap. But this scripts initializes only on page reload (ctrl+R or F5), that's because of turbolinks. How can i make it work the easiest way? <script> function initialize() { var myLatlng = new google.maps.LatLng(<%= place.latitude %>, <%= place.longitude %>); var mapOptions = { zoom: 16, center: myLatlng }; var map = new google.maps.Map( document.getElementById("map

How to create a Youtube style loading bar with Rails 4's Turbolinks?

﹥>﹥吖頭↗ 提交于 2019-11-29 02:11:09
问题 Is there a way to make a Youtube style loading bar (the inter-page across the top bar) with turbo-links. Turbolinks has loads of different callbacks so you could make a jumpy one across a few steps but is there a way to hook into the progress too? 回答1: nprogress-rails is probably just what you need. 回答2: Check your turbolinks version: $ gem list |grep turbolinks turbolinks (2.5.3) if your Turbolinks version < 3.0, add below code to you js file(for example: application.js ). Turbolinks

Rails 4 TurboLinks and jQuery Dynamic Links Not Playing Nice

妖精的绣舞 提交于 2019-11-29 02:02:53
I am developing an application in Rails 4.0 and I'm having an issue with turbolinks not playing nice with some jQuery code I have. I have a Quote model that has a related QuoteItems model. I am using accepts_nested_attributes_for and some jQuery to populate the line items form. When I click on a link bringing me to the new_quote_path, The dynamic link doesn't fire the javascript code. When I refresh the page, the form WORKS GREAT. I like turbolinks as it is super fast, but not sure how to get this to work in development. Here's some code. in quotes.js.coffee jQuery -> $('form').on 'click', '

turbolinks issues with bootstrap modal

大兔子大兔子 提交于 2019-11-29 01:56:52
I doing a modal like this: Link that shows the modal: <%= link_to "versão resumida", resumed_rep_life_animal_path(animal, :partial => true), 'data-toggle' => 'modal', 'data-target' => '#myModal', 'data-no-turbolink' => true %> Modal html itself: <div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-body"></div> <div class="modal-footer"> <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Fechar</button> </div> </div> But, the data-no-turbolink dont work as expected. If I refresh the page,

Re-rendering specific js file with turbolinks enabled

て烟熏妆下的殇ゞ 提交于 2019-11-29 00:12:26
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? 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).ready(initialize); $(document).on('page:load', initialize); If you use jQuery a lot, it is useful to install