Forum: Ruby on Rails Ajax-submit form on "check box onclick ": why this error?

Posted by Tom Ha (tom)
on 2010-03-09 19:02
Hi there,

I need to have a checkbox which ajax-submits a form.

The following code throws an error "index 112009 out of string". What's
wrong here?

==============================================
<% form_remote_tag :url => { whatever_url } do -%>

<%= check_box_tag 'whatever', nil, whatever, { :onclick =>
"#{remote_function('this.form.submit();')}", :disabled => false } %>

<% end -%>
==============================================

Thanks for any help with this!
Tom
Posted by anton effendi (Guest)
on 2010-03-09 19:07
(Received via mailing list)
I think...
Dont use #{....}

<%= check_box_tag 'whatever', nil, whatever, { :onclick =>
"remote_function('this.form.
>
> submit();')", :disabled => false } %>
>

But I dont because i never try it...
keep trying


On Wed, Mar 10, 2010 at 1:02 AM, Tom Ha <lists@ruby-forum.com> wrote:

> <%= check_box_tag 'whatever', nil, whatever, { :onclick =>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


--

Senior Rails Developer
Anton Effendi - Wu You Duan
Posted by Tom Ha (tom)
on 2010-03-09 19:14
Thanks for your answer. Unfortunately, if I try...

  :onclick => "remote_function('this.form.submit();')"

...then I get an error (by Firebug): "remote_function is not defined"

Any other ideas?
Posted by Tom Ha (tom)
on 2010-03-10 09:48
Anyone...?
Posted by Colin Law (Guest)
on 2010-03-10 10:41
(Received via mailing list)
On 9 March 2010 18:14, Tom Ha <lists@ruby-forum.com> wrote:
> Thanks for your answer. Unfortunately, if I try...
>
>  :onclick => "remote_function('this.form.submit();')"
>
> ...then I get an error (by Firebug): "remote_function is not defined"

What method called remote_function are you trying to call?  Can you
point me to the docs for it?

Colin
Posted by Tom Ha (tom)
on 2010-03-10 12:10
Hi Colin,

it's this one here:

http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001653

(in order to ajax-submit a form using form_remote_tag, see code 
above...)
Posted by Colin Law (Guest)
on 2010-03-10 12:59
(Received via mailing list)
On 10 March 2010 11:10, Tom Ha <lists@ruby-forum.com> wrote:
> Hi Colin,
>
> it's this one here:
>
> http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001653

Your code does not seem to be much like the example given, either in
the way it is invoked or in the parameter.

Colin
Posted by Tom Ha (tom)
on 2010-03-10 13:08
Any idea how the code would have to be, in order to achieve my goal? 
(see 1st post)
Posted by Colin Law (Guest)
on 2010-03-10 13:14
(Received via mailing list)
On 10 March 2010 12:08, Tom Ha <lists@ruby-forum.com> wrote:
> Any idea how the code would have to be, in order to achieve my goal?
> (see 1st post)

No, sorry, I have never done this.  Anyone else?

Colin
Posted by Ae Ae (roark)
on 2010-03-10 22:36
Hi Tom,

I came across your post looking for a solution myself. This is what's 
working for me:

<% form_remote_tag :url => { whatever_url } do -%>
<%= check_box_tag 'whatever', nil, whatever, { :onclick => 
"this.form.submit();", :disabled => false } %>
<% end -%>


Hope that helps, Cheers,
roark



Tom Ha wrote:
> Hi there,
> 
> I need to have a checkbox which ajax-submits a form.
> 
> The following code throws an error "index 112009 out of string". What's
> wrong here?
> 
> ==============================================
> <% form_remote_tag :url => { whatever_url } do -%>
> 
> <%= check_box_tag 'whatever', nil, whatever, { :onclick =>
> "#{remote_function('this.form.submit();')}", :disabled => false } %>
> 
> <% end -%>
> ==============================================
> 
> Thanks for any help with this!
> Tom
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.