Rails 4 boostrap3 gem installed but when my page loads the html displays then then bootstrap gets applied this happens very quickly on every page load. Why is the style not applied on load of page?
Make sure you are loading css and js files in header and they are not loaded asynchroniously.
Related
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.
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.
I am using twitter bootstrap installed by copying bootstrap.min.css, etc. into the vendor/assets folder.
When using rails forms validations, error messages appear using default styling, not the bootstrap styling I would expect (e.g. the h2 tag is much smaller and in a different text, the unordered list uses different bullets, etc.) How do I get bootstrap to override the default styling that rails uses when generating error messages for forms? I'm guessing this has something to do with the asset pipeline, but didn't see anything about overriding rails-generated content in the rails guide.
Thanks!
Sounds like you used some scaffolding which generated a CSS sheet. Go into app/assets/stylesheets and delete the stylesheet named "scaffolds.scss" (or just delete the parts you don't want).
To track down where that styling is coming from, you should use your browsers development tools. Inspect the element and it should tell you where the styling is coming from.
Rails 3 offer application.html.erb as a layout template. However, whenever you send request to access a controller view, the content of application.html.erb will be loaded again. This seems not efficient, since header, navigation, footer only need to be loaded once.
In addition, when you need to have a javascript code executed in $(window).load for application.html.erb and another js method executed in $(window).load for <controller>.html.erb, this will mess up. I think the reason is that $(window).load can only execute once for each page.
So I wonder what's the best Layout practice for Rails 3.
Thanks
Rails 4 includes Turbolinks, which will only reload the body of your website when a link is clicked, instead of reloading all of the assets like javascript and CSS. If you want to fine tune what gets loaded further, you can take a look at pjax, but I think for most applications Turbolinks will be sufficient.
I just started to use twitter-boostrap gem for my simple app.
When I check it loads some many javascript file which I believed it does not use in a particular page. just like show in the following image
http://i.imgur.com/Aluth.png
So the question, is it possible to manage which js file should be loaded in a page?
Thanks.