I imagine there’s a simple solution for this. I want to click a checkbox
and have a rails for submit immediately and save data to the database.
However, since this is a checkbox there’s no need to render anything
because either the checkbox is check or it’s not.
For example:
<%= form_remote_tag(:url => { :action => “save_data” }) %>
<%= check_box(“report”, “word”, :onclick => “this.form.submit()”) %>
<%= end_form_tag %>
Then in the controller I have a method called “save_data” that does the
usual active record saving of data, but I don’t need any rendering to be
done – I just need the data to be saved. If I leave out the “render
:partial” statement I’m obviously told the template for “save_data” is
missing. How can I get around this?
On 4/6/07, MenDAKE [email protected] wrote:
<%= end_form_tag %>
Then in the controller I have a method called “save_data” that does the
usual active record saving of data, but I don’t need any rendering to be
done – I just need the data to be saved. If I leave out the “render
:partial” statement I’m obviously told the template for “save_data” is
missing. How can I get around this?
Renders an empty response with status code 200
render :nothing => true
Andy D. wrote:
On 4/6/07, MenDAKE [email protected] wrote:
<%= end_form_tag %>
Then in the controller I have a method called “save_data” that does the
usual active record saving of data, but I don’t need any rendering to be
done – I just need the data to be saved. If I leave out the “render
:partial” statement I’m obviously told the template for “save_data” is
missing. How can I get around this?
Renders an empty response with status code 200
render :nothing => true
Thanks, that looks like what I need.
However, now I have another question. It seems that putting a
form.submit inside the Onclick of a checkbox doesn’t render the form
ajax style. Instead of updating the div with the appropriate id the
entire page is updated. Am I going about this wrong?