# ? Buttonless ?

**URL:** <https://discuss.rubyonrails.org/t/buttonless/46240>\
**Category:** rubyonrails-talk\
**Created:** [September 22, 2009, 2:56am UTC](https://discuss.rubyonrails.org/t/buttonless/46240 "2009-09-22T02:56:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dudebot](https://discuss.rubyonrails.org/u/Dudebot)\
**Post date:** [September 22, 2009, 2:56am UTC](https://discuss.rubyonrails.org/t/buttonless/46240/1 "2009-09-22T02:56:57Z")

</div>

I have this code, which is working quite well:

\<% form\_tag '', :method =\> 'GET' do %\> &nbsp;&nbsp;&nbsp;\<p\>\<%= radio\_button\_tag :report, 'by\_date', params[:report] ||= 'by\_date' %\>\<b\>By Date\</b\>\</p\> &nbsp;&nbsp;&nbsp;\<p\>\<%= radio\_button\_tag :report, 'by\_donor', params[:report] == 'by\_donor' %\>\<b\>By Donor\</b\>\</p\> &nbsp;&nbsp;\<p\>\<%= submit\_tag "Choose" %\>\<p\> \<% end %\>

\<%= render( :partial =\> "orders" , :object =\> @orders ) %\> (Inside of the \_orders partial is where params[:report] is processed)

But it's ugly in that pressing "Choose" is redundant--I want the partial action to happen when the user simply selects the radio button. Is there any way to do this?

Many TIA, Craig

---

<div class="post-metadata">

**Author:** ![Bill\_Walton1](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Bill\_Walton1](https://discuss.rubyonrails.org/u/Bill_Walton1)\
**Post date:** [September 22, 2009, 3:09am UTC](https://discuss.rubyonrails.org/t/buttonless/46240/2 "2009-09-22T03:09:32Z")

</div>

Hi Craig,

---

<div class="post-metadata">

**Author:** ![Dudebot](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dudebot](https://discuss.rubyonrails.org/u/Dudebot)\
**Post date:** [September 22, 2009, 3:41am UTC](https://discuss.rubyonrails.org/t/buttonless/46240/3 "2009-09-22T03:41:23Z")

</div>

Thanks, Bill! The docs for observe\_form are sparse:

"Observes the form with the DOM ID specified by form\_id and calls a callback when its contents have changed. The default callback is an Ajax call. By default all fields of the observed field are sent as parameters with the Ajax call.

The options for observe\_form are the same as the options for observe\_field. The JavaScript variable value available to the :with option is set to the serialized form by default."

...

observe\_field seems quite different... I've looked up various references on the web and played around without success. How would I use "observe\_form" with my code? I get the feeling the answer is simple, and I'm just missing it...

Many TIA, Craig

---

<div class="post-metadata">

**Author:** ![Dudebot](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dudebot](https://discuss.rubyonrails.org/u/Dudebot)\
**Post date:** [September 22, 2009, 3:57am UTC](https://discuss.rubyonrails.org/t/buttonless/46240/4 "2009-09-22T03:57:08Z")

</div>

This for example does not work: (index.html.erb) ... \<% form\_tag '', { :id =\> 'myform', :method =\> :get } do %\> &nbsp;&nbsp;&nbsp;\<p\>\<%= radio\_button\_tag :report, 'by\_date', params[:report] ||= 'by\_date' %\>\<b\>By Date\</b\>\</p\> &nbsp;&nbsp;&nbsp;\<p\>\<%= radio\_button\_tag :report, 'by\_donor', params[:report] == 'by\_donor' %\>\<b\>By Donor\</b\>\</p\> &nbsp;&nbsp;\<p\>\<%= submit\_tag "Choose" %\>\<p\> \<% end %\>

\<%= observe\_form( 'myform', &nbsp;&nbsp;:frequency =\> 1, &nbsp;&nbsp;:with =\> "report", &nbsp;&nbsp;:action =\> :index ) %\>

\<%= render( :partial =\> "reports" ) %\> ...

Any ideas? Again, many TIA, Craig

---

<div class="post-metadata">

**Author:** ![Chris\_Habgood](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@Chris\_Habgood](https://discuss.rubyonrails.org/u/Chris_Habgood)\
**Post date:** [September 22, 2009, 2:50pm UTC](https://discuss.rubyonrails.org/t/buttonless/46240/5 "2009-09-22T14:50:13Z")

</div>

This gives you an ajax response. \<%= radio\_button\_tag :report, 'by\_date', params[:report] ||= 'by\_date', :onclick =\> remote\_function( :url=\> { :controller =\> 'myforms', :action =\> 'do' } ) %\>

---

<div class="post-metadata">

**Author:** ![Bill\_Walton1](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Bill\_Walton1](https://discuss.rubyonrails.org/u/Bill_Walton1)\
**Post date:** [September 22, 2009, 3:26pm UTC](https://discuss.rubyonrails.org/t/buttonless/46240/6 "2009-09-22T15:26:28Z")

</div>

Hi Craig,

> This for example does not work: (index.html.erb)

What, exactly, do you mean 'does not work'? Is the Ajax request not firing? Are there no params? If there are params, are they not named what you expect?

If you're going to use/debug Ajax, you need to be using Firefox and the Firebug plugin. You will be able to see all requests, params, and responses in the Firebug NET tab, and all Ajax requests, etc. in the Console tab.

To help further, I'll need to know what you're seeing.

Best regards, Bill
