Forum: Ruby on Rails Using a Button to render partial

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Arch S. (Guest)
on 2006-04-15 06:50
Is there a way to render a partial using a button?  Basically in a
content div I want the user to launch a new sub content item in the same
div by clicking a button.

Any help appreciated.

Loving rails more and more everyday.
Pedro V. (Guest)
on 2006-04-15 08:18
Arch S. wrote:
> Is there a way to render a partial using a button?  Basically in a
> content div I want the user to launch a new sub content item in the same
> div by clicking a button.
>
> Any help appreciated.
>
> Loving rails more and more everyday.

link_to_remote("my button",:update =>'mydiv',:url =>{:action =>
:myaction})

You can stylish your link to look like a button.
You have to specify on myaction

def myaction
   render(:layout => false)
end

Hope this helps.

P

http://wiki.onrails.com.ar
Arch S. (Guest)
on 2006-04-16 09:20
Pedro V. wrote:
>
> link_to_remote("my button",:update =>'mydiv',:url =>{:action =>
> :myaction})
>
> You can stylish your link to look like a button.
> You have to specify on myaction
>
> def myaction
>    render(:layout => false)
> end
>
> Hope this helps.
>
> P
>
> http://wiki.onrails.com.ar

Wow that is cool.  I was looking for a hack to get AJAX style behavior
and Rails gives a method to do exactly that.

Apparently I need to just spend the time reading the api.

Thanks!
This topic is locked and can not be replied to.