Simple and quick Ruby on Rails double click protection

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!


One Comment on “Simple and quick Ruby on Rails double click protection”

  1. Thanks! Totally saved the day for me.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.