Welcome Guest | Login

Unable to figure out Ajax for form with checkbox

I'm about ready to give up on this, but figured I'd try here first to see if any experienced Rails coders might be willing to point me in the right direction. I'm working on a calendar application. For the event submission, I've got a form listing my top-level, parent categories, with checkboxes so the user can select categories. What I've been trying to code is, if a parent category box is checked, to have its children categories then appear underneath.

I've got the parent categories displaying like this

<table>
<% @main_categories.each do |category| %>
 <tr>
   <td><div id="category_list"><%= check_box_tag "event_category_id[]", category.id %>  <%= category.name %></div></td>
 </tr>
<% end %>
</table>


In my controller,
@main_categories = Category.find(:all, :conditions => ['parent_id = ?', '1'], :order => "name")


I've been trying to figure out how to use remote_function to get the child categories to display :onclick, but I just don't seem to be able to get this. If anyone understands how Ajax in this instance would work and could offer some guidance, I'd really appreciate it. Thanks.

2007-10-03 08:59 PM

Hi there - sure, what you need to do is pull out the Ajax updater code and use it directory.  No need for Rails tags, use HTML for the checkbox and javascript for the onClick="new Ajax.Updater..."

Feel free to post the html/javascript code you're working on and I'd be happy to help further.

2007-10-04 12:38 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!