Thanks Justin. Using "onsubmit" instead of "submit" worked like a
charm.
I will try and change the code so that each checkbox has its own ajax
call. I'm just a little concerned about how to tell the controller
that a particular checkbox is on or off. I'm sure that's a better way
to do it though. Thanks again!
On Jan 17, 12:11 pm, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> On Jan 17, 2008 1:39 PM, Jennifer Maas <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am using prototype 1.5 *I think*. I put version 1.5 in my public
> > javascript folder, so I assume that's the version it's picking up. Is
> > there an easy way to tell?
>
> Just look at the prototype.js file, it's right at the top. The latest
> version if 1.6.0, there are many changes from 1.5 to 1.6. Also there
> is a newer version of Scriptaculous (1.8) to go along with the new
> version of Prototype.
>
> > Here's the code to create the checkboxes (clicking them returns
> > unexecuted javascript):
>
> > <%= check_box_tag
> > replace_spaces(category.name),replace_spaces(category.name), false,
> > :name =>
> > "category[#{category.name}]",
> > :onclick =>
> > 'document.frm_categories.submit();' %>
>
> When you call submit like that, you are submitting the form through
> the normal form POST means, not the Ajax way.
>
> Why not just have individual checkboxes that have their own Ajax
> request and do away with the remote_form?
>
> <%= check_box_tag
> replace_spaces(category.name),replace_spaces(category.name), false,
> :name =>
> "category[#{category.name}]",
> :onclick => remote_function(
> :url => { :action => 'add_filter' }, :with => "'#{
> replace_spaces(category.name) }=' + this.value" %>
>
> I'm taking advantage of another Rails helper method, remote_function,
> which translates to a new Ajax request. See this page for more
> info:http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper...
>
> If you want to leave your code relatively untouched, and still use the
> remote_form combined with each click of a checkbox causing an complete
> form submit, try something like this:
>
> <% form_remote_tag :url => {:action => 'add_to_filter2'}, :html =>
> {:id => "frm_categories"} do -%>
> <%= check_box_tag
> replace_spaces(category.name),replace_spaces(category.name), false,
> :name =>
> "category[#{category.name}]",
> :onclick =>
> '$('frm_categories').onsubmit()' %>
> <% end -%>
>
> I think that will work.
>
> -justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---