How do you call a javascript function to do something when the response
is returned to the visitors browser?
Easy ey?
//Daniel
How do you call a javascript function to do something when the response
is returned to the visitors browser?
Easy ey?
//Daniel
Many of the built-in AJAX actions in Rails such as the link_to_remote
allow you to specify JavaScript to execute upon completion by setting
the :success attribute. In this example, I show the spinner div while
the processing occurs, and hide it when it is complete.
<%= link_to_remote( “#{state.title}”,
:update => “state_editor”,
:before => %(Element.show(‘spinner’)),
:success => %(Element.hide(‘spinner’)) ,
:url =>{ :action => “load_state”, :id => state.id }) %>
Hope this helps ~
Ben
On 3/24/06, Daniel [email protected] wrote:
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Ben R.
http://www.benr75.com
Thanks, thats what Im looking for.
Could someone please elaborate on how to override the setting of
success/failure attribute?
Thanks in advance
// Daniel
Ben R. wrote:
Many of the built-in AJAX actions in Rails such as the link_to_remote
allow you to specify JavaScript to execute upon completion by setting
the :success attribute. In this example, I show the spinner div while
the processing occurs, and hide it when it is complete.<%= link_to_remote( “#{state.title}”,
:update => “state_editor”,
:before => %(Element.show(‘spinner’)),
:success => %(Element.hide(‘spinner’)) ,
:url =>{ :action => “load_state”, :id => state.id }) %>Hope this helps ~
Ben
On 3/24/06, Daniel [email protected] wrote:
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails–
Ben R.
http://www.benr75.com
More info on what Im trying to do:
I submit a login form using ajax.
On the server side I check if the submitted info is valid.
Depending on if the submitted info is valid or not I send back different
partials.
If the info was invalid I would like to set the failure attribute so
that I can pop up a javascript alert in the browser.
Is this doable?
//Daniel
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs