Submit Form with AJAX on javascript event

I’m new to rjs and ajax…doing the example in RJS Templates for
rails.

I’d like to submit the form onChange…but my onChange code doesn’t
work as expected. I get the js code in the browser window…instead of
my updated page.

It does still work when I press the submit button though.

My form code:

<%= form_remote_tag :url => {:action => ‘log’}, :html => { :id =>
‘thought-form’} %>
<%= text_field_tag ‘thought’, nil, {:size => 40, :onChange =>
‘this.form.submit()’} %>
<%= submit_to_remote ‘Log thought’, ‘Check’ %>

This is what I see in the browser.

try {
new Insertion.Top(“thoughts”, “

\n\ta random thought\n

”);
new Effect.Highlight(“thoughts”,{});
Form.reset(“thought-form”);
} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘new
Insertion.Top(“thoughts”, “

\n\tchris.ca EXIST\n

”);\nnew
Effect.Highlight(“thoughts”,{});\nForm.reset(“thought-form”);’);
throw e }

Any Ideas?

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