Ruby on Rails
Monday, February 11, 2019
Rails works perfectly fine without Javascript.
I'm veering into the pedantic here...
Rails certainly can work fine without Javascript. As you say in this booking example, you can certainly just re-render the page completely on the server (even if it is 'icky'!)
However to really use rails without javascript you would have to be careful to avoid the many standard features which are implemented using js.
e.g.
<%= link_to "test link", test_path, method: :post %>
This submits via POST normally, but via GET if you disable javascript in your browser (or if you don't include the standard js includes)
When I started writing Rails, it was normal to consider that a meaningful proportion of your customers would not have js, and write the app to handle that case.
Today, I certainly wouldn't waste time coding for the 'what if they don't have js' scenario.
cheers,
Rob
On Mon, 11 Feb 2019 at 11:17, Rob Zolkos <rob@zolkos.com> wrote:
This is totally doable without javascript. Rails works perfectly fine without Javascript.You will need to re-render the page from the server on any change/submit. That is ok (I suspect the exercise they are trying to teach you is that these sorts of interactions *can* be done in a server rendered way but when you get to the JS modules it will be easier and a better experience for the customer).Each seat would need to be a submit button and on the server you would check the value of params[:commit] to validate. Once the seat is assigned/allocated you would re-render the page and show the correct styling.<% @seats.each do |seat| %><% if seat.occupied %><div class="occupied">X</div><% else %><%= f.submit seat.id, class: "available" %><% end %><% end %>--On Mon, Feb 11, 2019 at 9:55 AM Daniel Toma <tomada36@gmail.com> wrote:--Hi, thank you very much for replying. I forgot to mention a biggie: that JS isn't allowed. I can use CSS and Bootstrap but no JS allowed in this particular project (JS is our next module).I sense that Ruby (on Rails) isn't particularly geared for this type of interactivity.
On Sunday, February 10, 2019 at 2:25:30 AM UTC-5, hasan...@gmail.com wrote:Daniel,On Sat, 9 Feb 2019 at 23:13, Daniel Toma <toma...@gmail.com> wrote:I just can't think of how this would be done, and I was wondering if anyone had an idea.While you could use ruby for this, a Javascript solution is going to be less heavy on the server. Simply define a class for blue and a class for red as follows in CSS:.available { background-image("//location/of/green/image"); }.taken { background-image("//location/of/red/image"); }.na { background-image("//location/of/unavailable/image"}; }Now that these are defined, you can set the class on submit using jquery's .addClass after removing the old one using .removeClass. Good luck, matey and let me know if you need further assistance.--If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.Envoye de mon portable
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6114bedb-e26d-4da1-b958-bc7efd99ada3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/wgTcZ7C8mho/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ6MPzJX3muMz1UaJ%3DvZZYEpZ9x4mMgvv26ZLAr0Bhqswc7bBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hobbyist Software is a trading name of Hobbyist Software Limited. Registered office 12 Fraley Rd, Bristol, BS93BS. Registered in England. Company no:7876492
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACTOy%2BrMHKB0sCJ2XEMJT5XQKZazLUBdwD3ZUHn4axamj%3DRfWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment