why do i remove turbolinks before using angular - ruby-on-rails

gem install rails -v 4.1
rails new angular_example
Before using angular i'm recommended to remove turbolinks.
So why do i have to remove it and what's the purpose of turbolinks?

Because Angular and Turbolinks can conflict with one another,angular doesn't work correctly. So we disable turbolinks.
Turbolinks handle the request made by browser. For example AJAX request to the server, waiting the answer, deleting the old content and replacing it with the new content

Related

Rails 5 Turbolinks appears to reload page

I am still new to Turbolinks and unsure whether it is working correctly. I have a new rails app that I've created with Turbolinks enabled by default. I am using the link_to rails helper to build some links. When I click on one of the links the page reloads in the browser. I was under the impression that this should not occur as only the body should be swapped using AJAX. Is there any additional attributes I need to add to my link or additional configuration I need to set up?
Make sure that you have the Turbolinks js loaded in the page. If you are using webpacker and removed the default application js that used the asset pipeline you will probably need to use Turbolinks from npm, import it and then call Turbolinks.start() in your entry file.

How to completely remove all of turbolinks from a Rails 5 project

I've read through the other available questions and answers and they don't solve my issue. I recently looked to remove turbolinks from my project because I was having problems setting up event listeners. Suggestions for modifying the jquery to use the turbolinks equivalents weren't working, so I decided to remove it entirely for now to unblock myself.
I've done the following:
Remove the gem from Gemfile
Bundle (confirmed in the bundle turbolinks is no longer listed)
Removed turbolinks attributes from links in the head
Removed the require from the application JS
Restored my JS file to the original jQuery implementation
However, the problem persists on production (Heroku). Everything continues to work locally. I was inspecting the source assets on production and noticed I can find traces of turbolinks in the compiled js file. I don't know if this is causing the problem and I don't know where it's coming from so I haven't been able to remove it to test.
My JS file is set up like so:
$(document).ready(function() {
console.log('Listener setup working...');
....
Any ideas greatly appreciated.

many turbolinks when I browser back

I am developing in Ruby on Rails.
I get many turbolinks when I use browser back like this.
have many turbolinks linke this
Although I move page by clicking a tag, I have no turbolinks.
Only I use browser back, I have many turbolinks loading and reload webpage many times.
How can I browser back smoothly just like I click a tag.
SO! not clear your question, for suggestion if you do not need turbolinks on your application then remove the gem 'turbolinks' from Gemfile update the bundle and remove //= require turbolinks this line from assets/application.js and finally restart the server.
Number 2
If need to disable turbolinks for specific link then use data-turbolinks="false" for this link which you need to not use turbolinks like below
Disabled
See more about turbolinks on there documentation
Hope it helps

How do I use Turbolinks and local_time together?

I've noticed recently, probably since installing Rails 5 that the local_time gem doesn't work properly on pages where the link was internal (through turbolinks). If the link to the page was external or the browser refreshed, or turbolinks is disabled, local_time works properly.
Does anyone know how to use these together?
I needed to initialize the local time on TurboLinks load. This event provides a chance to do those things that would have run at document ready. The JavaScript is:
document.addEventListener("turbolinks:load", function() {
LocalTime.run();
});

Can't get pjax to work on Rails

I'm trying to get pjax to work on a Rails app but none of the links are being annotated with pjax. I think pjax isn't really being loaded. I'm using pjax_rails and am basically following the railscast instructions but using //= require jquery.pjax instead of just pjax. I'm also using it with bootstrap which may cause an issue but I'm not sure. My other thought is that is that the pjax javascript isn't being loaded and I need to run something like $('a').pjax('[data-pjax-container]')
To be clear the main problem is that pjax isn't being loaded client side and thus when I make requests the X-PJAX header is not being set.
Finally got it working. First problem was that the unbeknownst to me the assests pipeline was turned off so the pjax javascript file wasn't being included. Instead I went with the pjax rack gem and dumped it into the public directory. Then I created a new javascript file with $('a').pjax('[data-pjax-container]') and it works! Although I'm not sure why I need to manually call that javascript when all the documentation seems to point to the fact that it should be already there.

Resources