Simple and quick Ruby on Rails double click protection
Posted: December 6, 2011 Filed under: Ruby on Rails | Tags: double click protection, ruby on rails 1 Comment »RoR to me is one of the best web frameworks I have used. Simply because of how fun ruby code is and all the mundane things RoR handles. I have used django, I code at my day job using c#/asp.net/mvc. When I hear the odd person complain how shitty RoR is, I know for fact they haven’t developed anything using the framework; if they did, they wouldn’t be complaining.
Cool tidbit to stop double clicks on buttons. I saw lots of examples hacking up javascript code for this and using server side checking (is the safest) on the time difference between clicks.
I just wanted something quick so I found out this rad simple trick.
<%= f.submit "Create", :disable_with => 'Saving...' %>
Use :disable_with as parameter on the submit helper, and BAM! No more double clicks. I am sure there is caveats to this, I haven’t looked into the wiring yet.
Simple, love it, Outta Here!
Thanks! Totally saved the day for me.