Hi Alex,
Alex W. wrote:
What html does the above code create? It should look like:
The answer and some variations on the theme below.
<%= form_remote_tag :url => {:controller => ‘create’,
:action => ‘check_js’
}
generates
<%= form_remote_tag :url => {:controller => ‘create’, :action =>
‘choose_start_point’},
:html => {:action =>
url_for(:controller
=> ‘create’, :action => ‘check_js’)} %>
generates:
and, ------------------------------------------------------------
<%= form_remote_tag :url => {:controller => ‘create’, :action =>
‘check_js’},
:html => {:action =>
url_for(:controller
=> ‘create’, :action => ‘choose_start_point’)} %>
generates:
------------------------------------------------------------
So my question from looking at the above is…
Is the form action ever invoked? The :url option clearly controls the
target of the Ajax request. So what’s the order of operation? It looks
to
me like maybe the form is going to try to invoke some js via the
onsubmit.
If js is not enabled, I assume then the form action takes over.
Watching the console in Firebug, I can see the POST happen, then it
disappears from the console, and the ‘no_js’ page then renders.
Is that the way it’s supposed to work? If so, what sort of response is
the
form waiting for?
My problem is that with this in the view…
<%= form_remote_tag :url => {:controller => ‘create’, :action =>
‘check_js’}
%>
With this in the controller…
def check_js
respond_to do |wants|
wants.html {redirect_to :action => ‘no_js’}
wants.js {redirect_to :action => ‘choose_start_point’}
end
end
I’m getting the ‘no_js.rhtml’ template rendered whether Javascript is
enabled through the menu via Tools->Options->Content or not.
And the same results obtain when I put this into the controller…
<%= form_remote_tag :url => {:controller => ‘create’, :action =>
‘check_js’},
:html => {:action =>
url_for(:controller
=> ‘create’, :action => ‘no_js’)} %>
I can see the ‘POST’ message in Firebug, then it disappears, then the
‘no_js.rhtml’ page renders.
Clearly I’m misunderstanding and/or misinterpreting something. Any help
figuring out what it is would be much appreciated!
Thanks,
Bill