October 4, 2006
Auto disabling the submit button with KRJS
Benjamin over at RubyOnRailsBlog was recently wondering about how to painlessly disable a submit button to prevent the user from hitting it multiple times.
This requires some sort of javascript hackery to achieve, but the easiest way I’ve found to do this is with my trusty old KRJS pocketknife.
-
# in application controller
-
-
def on_commit_click
-
render :update |page| do
-
page[‘commit’].disabled = true
-
page << "$(’commit’).form.submit();"
-
end
-
end
-
-
# in the form
-
-
<%= submit_tag ‘Submit’, :id=>’commit’ %>
This will add this behavior for all submit buttons with the ‘commit’ id. The hardest part here is remembering to add the ‘commit’ id.
Requires: KRJS Plugin
Filed by Kevin Olbrich at 8:52 pm under AJAX, Ruby on Rails, User Interface, plugins
4 Comments
Great idea of using krjs to achieve this globally. Now, how do we remove the disabled aspect once the commit / post has completed?
If you are using a remote form, you can add an ‘after’ callback that calls a script like “$(’commit’).disabled = false”. This will fire off when the AJAX action returns.
You could also add a similar line at the end of an RJS template render to turn it back on.
???? ??????! ? ????? ??????? ? ?????? ??????? ?????? ? ??????? ???????? ???????????. ??? ?? ????? ?????? ????????????? ????? ?????????????? ????????? ????? midland. ????? ?? ?????? ?? ???? ? ?? ?? ????? midlands.ru ?????? ?? ???? ?? ???????. ???-?????? ??????????? ??? ?????? ??? ??? ?? ?????????? ?
Good afternoon
Thus using the name and the shape of the brand pills a manufacturer producing generic medications will be accused of the copyright infringement. cheap online
Pa!!!
________________________________
where to buy in the united kingdom :)