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

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

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 [email protected] wrote:

<%= check_box_tag ‘whatever’, nil, whatever, { :onclick =>

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Senior Rails Developer
Anton Effendi - Wu You Duan

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?

On 9 March 2010 18:14, Tom Ha [email protected] 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

Anyone…?

On 10 March 2010 11:10, Tom Ha [email protected] 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

Any idea how the code would have to be, in order to achieve my goal?
(see 1st post)

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…)

On 10 March 2010 12:08, Tom Ha [email protected] 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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs