Topic: RJS and link_to_remote

Hi everyone,

When using link_to_remote, there are parameters to specify for :update => 'foo' for when the request begins, ends, fails, etc.

Does anyone know how to implement the same thing in RJS?

Brandon Taylor
Sr. Developer

Dell

Re: RJS and link_to_remote

the main difference is just that you don't use :update.
:update sets an ID of a tag that should be updated with the HTML returned by the server. if you use RJS, you send back JavaScript, not HTML. And in the JavaScript, you define what to update etc.

you can still use :loading etc. to show and hide e.g. a spinner GIF Image ...

the rest you do in the RJS template:

if @user  # user was saved successfully
  page[:login].replace_html "Login successfull"
  page[:login_form].hide
else
  page.[:login].replace_html "Login failed"
end

etc.pp....

Re: RJS and link_to_remote

Thank you very much for the reply! I thought that RJS completely took over those other options. I kept looking for examples that showed how to use :before, and :success within RJS, but couldn't find any at all.

RJS is such a powerful feature of Rails. I have several books and an RJS template guide from O'Reilly, but there really isn't a definitive guide to RJS anywhere that I've found. Maybe I'll have to put one together as I improve my skills.

Again, many thanks!

Brandon Taylor
Sr. Developer

Dell