RoR with JavaScript disabled

Is there any fallback mechanisms in Ruby on Rails 3.2 and 4.0 when someone has JavaScript disabled?

How would an application react, specifically when using ajax request. Would it fallback to normal requests?

I ask this because I need a website which also can handle requests from text browsers for disabled people.

What are some strategies if there is no default fallback.

Answers:

Answer

See this post. Stop loading the page if Javascript is disabled

In general I can't really think about any fallback mechanism here - note that huge part of requests done by rails are in fact ajax requests, as it is impossible to send PUT or DELETE over (Instead of delete request, rails send ajax post request with data: {"_method"="delete"}).

In short, for me disabling JS will break the page heavily, I'm gona test it today.

Answer

I'm not well experienced with RoR, but I suspect this is more a question of how you design your front-end architecture. My limited understanding is that RoR didn't provide any javascript "out of the box"; it's default state is to create views that produce flat HTML, which you can dress up how you like with JS and CSS.

Your HTML should be written such that the user should be able to get to all the content they are most interested in, without having to rely on JavaScript to do it. This means you should only use JS to augment the experience. In the language of common front-end practice, do progressive enhancement.

Answer

After some research I found the answer:

Ruby on Rails uses unobtrusive javascript to accomplish this. Any Ajax request will then gracefully "degrade" to a normal POST or GET request if javascript is disabled. The only action that will not be working out of the box is delete since it is the only request that is not fully supported by all browsers natively and needs js.

Find out more about that in that railscast: http://www.youtube.com/watch?v=t_MBLfrKTiE

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.