turbolinks

Masonry Jquery in Rails - doesn't work without refreshing the page

*爱你&永不变心* 提交于 2020-01-06 05:52:28
问题 I am currently following John Elder's book about building Pintinterest clone using Ruby on Rails.The problem is that Masonry Grid Layout works only when I refresh the page. When I click the link to the list of pins, everything goes to the left side. I tried to fix turbolinks, coffee script, application.js but I gave up after three days. This is my github: https://github.com/Gelin1984/Imager2018 This is my Heroku App: https://imager2018.herokuapp.com/ Coffee Script: $ -> $('#pins')

Facebook plugin page in Rails Turbolinks doesn't load

跟風遠走 提交于 2020-01-06 02:52:06
问题 in my Rails app I am loading Facebook plugin page, but because of turbolinks it doesnt load each page (only sometimes). I tried this script on this page , but now it never loads. What did I do? I created facebook.coffee with this script: $ -> loadFacebookSDK() bindFacebookEvents() unless window.fbEventsBound bindFacebookEvents = -> $(document) .on('page:fetch', saveFacebookRoot) .on('page:change', restoreFacebookRoot) .on('page:load', -> FB?.XFBML.parse() ) @fbEventsBound = true

Unable to use flash when rendering same page with Turbolinks

两盒软妹~` 提交于 2020-01-05 08:54:36
问题 I am trying to show flash message after hitting the update endpoint. I want to keep user on the same page and tell him that the info has been updated. I have turbolinks enabled. Here is how my action looks like: def update @form = Form.find(params[:id]) if @form.update(form_params) respond_to do |format| flash.now[:notice] = "Form updated successfully" format.html { render 'edit' } format.js { render 'edit' } # format.html { redirect_to edit_form_path(@form), notice: "Form updated

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

蓝咒 提交于 2020-01-02 21:54:34
问题 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() {

Polymer JS conflicts with Rails Turbolinks

瘦欲@ 提交于 2020-01-02 06:09:46
问题 Trying to use PolymerJs with a Ruby on Rails project with Turbolinks enabled. The initial loading of Polymer components works,but when I click on a link the new page renders, but my Polymer components are not reinitialized. Instead they look as if no JS has been run on them at all. I am loading polymer components and platform in the header, so they are not loaded with the 'page changes' (this is how turbolinks works - it only reloads the body). I seem to be able to 'fake it' by doing the

Ruby on Rails prevent Turbolinks from hijacking AJAX action

一世执手 提交于 2020-01-02 04:40:06
问题 I am following along the RoR getting started guide and adding a few things as I go along. Specifically, what I would like to achieve is that in step 5.13 Deleting Articles, I delete an article using AJAX instead of using the standard pattern. I want to do so in a way that fits in best with the RoR way of doing things. After reading the Working with JavaScript in Rails chapter, the following steps seemed like the way to go: Add property remote: true to the link_to helper (See code snippet A)

Unable to unbind event listener - trouble with turbolinks caching

会有一股神秘感。 提交于 2020-01-01 17:09:17
问题 I'm binding then unbinding the ready event listener to the document. $(document).bind("ready", readyEventHandler); function readyEventHandler() { // run some code $(document).unbind("ready"); } The code produces no errors and will work. However, my javascript is cached and duplicates the code so I'll end up with having this code run more than once if I go back and then forward a page in the browser. When this happens, the ready event listener is not called at all. Am I properly unbinding this

Facebook Like Box social plugin doesn't work with Turbolinks

佐手、 提交于 2019-12-31 01:33:28
问题 I'm using the Like Box social plugin (https://developers.facebook.com/docs/reference/plugins/like-box/) and it works great. Problem is that I'm using it within a Rails 4 application with Turbolinks. Whenever I reload a page, the like box shows up. If I click on any link, the next page loads and the Like Box doesn't show up. I tried this already but didn't worked =/ http://reed.github.io/turbolinks-compatibility/facebook.html Any ideas on how to solve this problem? 回答1: The link you have

rails 4 with turbolinks and window load

邮差的信 提交于 2019-12-29 07:33:09
问题 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

Error-prone code randomly started working, but then broke again upon refresh

被刻印的时光 ゝ 提交于 2019-12-25 07:07:18
问题 I'm trying to install the "selectize-rails" gem. I was having a lot of trouble ( TypeError: $(...).selectize is not a function ) so I gave up for a while and worked on unrelated things. Then I returned to it, and the gem was suddenly working, though none of the code I had changed was at all relevant to it. I then altered one line of code and refreshed the page to see the result, and it once again displayed the same error in the web console it had before: TypeError: $(...).selectize is not a