Link_to_function with submit

I looked everywhere but couldn’t find it.

I don’t want a submit_tag or image_submit_tag but a normal link that
submits my form.

Normally I would do this with a javascript like

function sendForm ()
{
document.forms[0].submit();
}

but this doesn’t work with form_remote_tag

link_to_function( ‘Send’ , “sendform();”)

So the question is:
how do I send my ajax form?

Thanks in advance
Peet

Peter, I did not try it myself, but I believe you can create helper
similar to the submit_to_remote, but creating link instead of button

looking at the source code

184: def submit_to_remote(name, value, options = {})
185: options[:with] ||= ‘Form.serialize(this.form)’
186:
187: options[:html] ||= {}
188: options[:html][:type] = ‘button’
189: options[:html][:onclick] = “#{remote_function(options)};
return false;”
190: options[:html][:name] = name
191: options[:html][:value] = value
192:
193: tag(“input”, options[:html], false)
194: end

it should be easy to create submit_to_remote_as_link and change
“input” on line 193 to “a” and amend related attributes (like :type to
:href)

just an idea

there is nothing in the link that you can hide with the submit button

Thanx guys.

I will have a look at it.

Emin H. wrote:

Peter, I did not try it myself, but I believe you can create helper
similar to the submit_to_remote, but creating link instead of button

looking at the source code

184: def submit_to_remote(name, value, options = {})
185: options[:with] ||= ‘Form.serialize(this.form)’
186:
187: options[:html] ||= {}
188: options[:html][:type] = ‘button’
189: options[:html][:onclick] = “#{remote_function(options)};
return false;”
190: options[:html][:name] = name
191: options[:html][:value] = value
192:
193: tag(“input”, options[:html], false)
194: end

it should be easy to create submit_to_remote_as_link and change
“input” on line 193 to “a” and amend related attributes (like :type to
:href)

just an idea

For security reasons you really should use a post to submit the form, a
link is an exposure.