render a partial on buttonclick?

I currently have a link to a Login screen, but its a separate page althogether. I have created a partial that is just the login box and password, and would like that partial to appear at a place on the page when the user clicks the link. Anyone know where I can find out how to do this?

Thanks so much.

You use link_to_remote instead of link_to… then you have the destination be a controller that just renders your partial and puts the result in that div. Pretty easy actually.

<%= link_to_remote "Delete this post", :update => "login_form",

    :url => { :action => "show_login_form", :controller=>"login" } %>

  <div id="login_form">
  </div>

Then in your controller, assuming you have a partial at app/views//login/_form.rhtml you just do

displays the login form partial… used by an AJAX request

def show_login_form render :partial=>“login/form” end

You can do a lot more cool stuff though… There’s a really good O’Reilly shortcut on RJS, but sadly I forget what it’s called… I think it’s RJS Templates for Rails or something. Quality read, and helps you get started quite quickly.

oh wow that does sound easy, I'm gonna try it out. I'll respond on how it works out... Thanks so much!

Ok so some of it worked, but not all of it. I have the partial "app/ views/login/_login_small.rhtml" that has this:

What’s your controller’s action look like that does the rendering?

Use a link_to_remote for the link. In the action it calls,

render :page do page[:id_of_place_on_page].replace(:partial => 'path_to_partial') end

don't forget to setup the variables used in the partial in the action
as well.

Niels

Couldn't you also do this in your controller?

# displays the login form partial... used by an AJAX request def show_login_form    render :partial=>"login/form", :layout => false end

So it wouldn't render the layout for that action?

Jacqui

Here is my action:

I'm looking for the same effect as http://www.digg.com when you click login...