Ajax submit: Clicking 'Submit' vs. hitting ENTER

Hi there,

Has anyone an idea why the below form
- submits correctly when I click the 'Submit' button
- but does call the 'new' action instead of 'create' when I hit ENTER?

<% form_remote_tag :html => { :action => url_for(:controller => 'pages',
                                                 :action => 'create') }
do -%>

  <%= text_field :page, :title %>
  <%= submit_to_remote 'blah', 'Submit', :url => {:controller =>
'pages',
                                                  :action => 'create'}
%>

<% end -%>

Thanks a lot for any hints!
Tom

Firstly it may be worth checking the html of the page is valid (view
the source in your browser and copy and paste the complete html into
the w3c html validator - find it with google if necessary).

Assuming html is valid is it possible that Enter is hitting a
different button or link on the page? Does the log give any clues?
I seem to remember a discussion here about this a little time ago, but
I don't remember the result. A bit of searching here and googling may
be useful.

Colin

Besides the above, use FF/Firebug to

1) confirm there are no JavaScript errors occurring
2) compare the network traffic generated by each event

FWIW,

Hi there,

Has anyone an idea why the below form
- submits correctly when I click the 'Submit' button
- but does call the 'new' action instead of 'create' when I hit ENTER?

<% form_remote_tag :html => { :action => url_for(:controller => 'pages',
:action => 'create') }
do -%>

<%= text_field :page, :title %>
<%= submit_to_remote 'blah', 'Submit', :url => {:controller =>
'pages',
:action => 'create'}
%>

<% end -%>

Well it should be ok to have that submit tag just be a normal submit
tag. Secondly if my memory is correct, passing the html => :action
option is only for setting up a fallthrough for if the user doesn't
have javascript (check what gets generated). You also need to say
something like form_remote_tag :url => {:controller => pages ...

Fred

You should confirm that your page has multiple form_tags? as like
form within another(inner forms).
actions is going to the first form action when you are using 2 forms
in your page
You can try with the following
<%=javascript_include_tag "prototype"%>
<form>
  <%= text_field :page, :title %>
  <%= submit_to_remote 'blah', 'Submit', :url => {:action =>
'create'},:update=>"SS"%>
</form>
<div id="SS"></div>

You should confirm that your page has multiple form_tags? as like
form within another(inner forms).
actions is going to the first form action when you are using 2 forms
in your page
You can try with the following
<%=javascript_include_tag "prototype"%>
<form>
  <%= text_field :page, :title %>
  <%= submit_to_remote 'blah', 'Submit', :url => {:action =>
'create'},:update=>"SS"%>
</form>
<div id="SS"></div>

You should confirm that your page has multiple form_tags? as like
form within another(inner forms).
actions is going to the first form action when you are using 2 forms
in your page
You can try with the following
<%=javascript_include_tag "prototype"%>
<form>
  <%= text_field :page, :title %>
  <%= submit_to_remote 'blah', 'Submit', :url => {:action =>
'create'},:update=>"SS"%>
</form>
<div id="SS"></div>

Thanks for all the feedback!

Fred's nailed it and all other hints were instructive as well!