David M wrote:> Hi,
>
> I''ve looked through the api and I can''t seem to find the
functionality
> that I''m looking for. I want a link that, when clicked, will
replace the
> content of a div with the rendered content of another action. Something
> like what you can accomplish when you use remote_form_tag and then have
> the reply replace the content of a div in the page. I''m sure this
must be
> possible from a link, but I can''t seem to figure out what to do.
>
> Thanks,
> David
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
You could use link_to_remote to call an action that renders the content
you want to fill the div with. You could do this by setting
:update=>"some_div_name" or by leaving out update and by using an
rjs
file with the name of the action that the link_to_remote calls.
Examples
link_to_remote "Change Content",
:url => { :action => "change_content"},
:update => "mydiv"
or
link_to_remote "Change Content", :url=> { :action =>
"change_content"}
and then have a .rjs file named change_content.rjs with contents
page.replace_html "mydiv", :partial =>
''partial_you_want_to_put_into_div"
Good Luck,
Matthew Margolis
blog.mattmargolis.net