# Using a Button to render partial

**URL:** <https://www.ruby-forum.com/t/using-a-button-to-render-partial/57861>\
**Category:** Rails\
**Created:** [April 15, 2006, 4:50am UTC](https://www.ruby-forum.com/t/using-a-button-to-render-partial/57861 "2006-04-15T04:50:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 15, 2006, 4:50am UTC](https://www.ruby-forum.com/t/using-a-button-to-render-partial/57861/1 "2006-04-15T04:50:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 15, 2006, 6:18am UTC](https://www.ruby-forum.com/t/using-a-button-to-render-partial/57861/2 "2006-04-15T06:18:17Z")

</div>

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](http://wiki.onrails.com.ar)

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 16, 2006, 7:20am UTC](https://www.ruby-forum.com/t/using-a-button-to-render-partial/57861/3 "2006-04-16T07:20:51Z")

</div>

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](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!
