How to disable temporarily a form using RJS templates?

This was created for exactly why you are trying to do. All this actually does is add the data attribute 'data-disable-with' to the submit button.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

I am using Ruby on Rails 3 and I would like to use RJS callbacks. I read from here that there are following callbacks: :create, :uninitialized, :loading, :loaded, :interactive, :complete, :failure, :success, but how to use them? Can someone give me an example?

Or post links to some useful resource? In my case I would like to disable a simple form after clicking on the submission button and until saving is completed. The form is like this: true, :id => "form_id" ) do |f| %> { :id => "text_field_id" } ) %> { :id => "file_field_id" } ) %> "button" %> P.S.: I read about the file 'RAILS_ROOT/public/javascripts(application.

Js' but online there isn't good documentation. Ruby-on-rails ruby ajax ruby-on-rails-3 callback link|improve this question asked Feb 4 '11 at 1:10user5020522,0161627 87% accept rate.

This was created for exactly why you are trying to do. All this actually does is add the data attribute 'data-disable-with' to the submit button. If you actually want to disable the whole form you could take the logic directly from your javascript driver in rails and change it to disable the whole form.

As an example the disable-with code for the jQuery driver is /** * disable-with handlers */ var disable_with_input_selector = 'inputdata-disable-with'; var disable_with_form_selector = 'formdata-remote:has(' + disable_with_input_selector + ')'; $(disable_with_form_selector). Live('ajax:before', function () { $(this). Find(disable_with_input_selector).

Each(function () { var input = $(this); input. Data('enable-with', input.val()) . Attr('value', input.

Attr('data-disable-with')) . Attr('disabled', 'disabled'); }); }); $(disable_with_form_selector). Live('ajax:complete', function () { $(this).

Find(disable_with_input_selector). Each(function () { var input = $(this); input. RemoveAttr('disabled') .

Val(input. Data('enable-with')); }); }).

Obviously for prototype you need to look in the rails. Js file for prototype as this is the jQuery version, I don't have any prototype Rails 3 apps to hand. – Steve Smith Feb 4 '11 at 12:55.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions