Do Rails turbolinks work in Phantomjs and if not, why? - ruby-on-rails

I've just tried to test a bit of JS that's supposed to fire on page load after a turbolink is clicked. Although I have verified it works in Chrome, Phantomjs doesn't seem to work and appears to be using normal links. I saw that some browsers don't support the HTML5 history API properly yet, but surely Phantomjs, being based on Webkit, should not be one of them?

Related

Rails needs page refresh to render correctly bootstrap markdown

I am developing an app using Ruby on Rails. In a specific view I have a textarea that uses Bootstrap Markdown.
The problem is that each time I visit that view, the textarea is rendered completely plain, without the Markdown functionality. Hitting F5 (refresh) renders the form correctly.
I tried to clear my browsers cache etc, but no luck. I always have to hit refresh to see the page correctly.
What may cause that?
Edit:
I am using this Markdown Plugin
I have also included the js files as stated in this question.
The turbolinks gem has been known to interfere with other javascript files and it's recommended that you remove it completely unless you really need it.
As Mohammad AbuShady said in his comment, you'll need to edit the part of the javascript files for your markdown that tells the page to start rendering. In your case this involves adding
$("#some-textarea").markdown({autofocus:false,savable:false})
inside page:load on the relevant pages.
In case you need turbolinks still, I found this very helpful: JQuery gets loaded only on page refresh in Rails 4 application
I had the same issue and adding jquery-turbolinks gem allowed the bootstrap-markdown editor to load perfectly for me.

Rails form not working after link_to

When I click on a link and move to a new page, my form doesn't submit.
It works normally if I refresh though. It also works normally after disabling Turbolinks.
How can I resolve this and keep using Turbolinks?
jquery.turobolinks gem sorted out a similar issue i was having. Just make sure you include it directly after jquery.
It just makes all your js bindings etc still work with turbolinks

Mod Pagespeed adding noscript when js enabled

I have the apache mod pagespeed installed, everything appears to be working ok.
I am using it on my ruby (1.9.3) and rails (3.2) app. I recently installed the gem 'turbolinks'.
Now the URLs on my site are getting ?ModPagespeed=noscriptadded after the trailing slash. This didn't happen before I added turbolinks.
Why does the page speed tool append ?ModPagespeed=noscript to the end of URLs and how can I prevent this?
If turning off a few of the mod pagespeed options were to help then I can maybe do that with no performance loss, eg, minifying js is something I do pre deploy in a precompile, likewise, the Rails asset pipeline does a good job of combining individual .js and .css files into compiled single files etc. Therefore, turning off combine javascript wouldn't be a problem. However, I don't know if this is what is causing it, as I implied I believe it is to do with the interaction of turbolinks, my app's http requests and the pagespeed module just not noticing that js is turned on.
I must admit I find it odd that I can't find even a remotely similar query to this online.
The redirect to ?ModPagespeed=noscript occurs in a meta-tag in a block. mod_pagepseed inserts this block when applying a filter that requires JavaScript to function. One example is lazyload_images, where the markup points to a blank image, and JavaScript is inserted into the page to point to the correct image.
The blocks are not needed for optimizations to JavaScript files; such optimizations will have no effect for browsers with JS disabled.

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.

Rails css changes not being saved

I'm learning to develop a web app using Rails on mac osx. I just added some css styling to my webpage. But every time I edit it and save it, and run rails s I cannot see the changes I made in the CSS on my webpage. I tried doing a hard refresh using COMMAND+SHIFT+R as well, but no luck. Any one know what's going on? I'm using firefox by the way.
Most likely, the css is being cached by the the web server. In your view, you need to add an autogenerated timestamp at the end of the css file name like so:
app.css?t=12044402444
or disable caching in your web server of choice.

Resources