I’m trying to use respond_to to redirect visitors who have JS turned off to a different page. The problem I’m having is that respond_to is sending everybody there. It’s not recognizing that JS is turned on in the browser. The wanted_html.rhtml file below is rendered whether I’ve got JS turned on or off. I’ve looked at the Accept headers being sent from the form_remote_tag button using Live HTTP Headers. The headers are exactly the same whether JS is turned on or off. That seems wierd.
Another wierd thing. When the form is submitted, in the Firebug console, I see a POST, then it disappears. I put the sleep() call in below to verify. The POST is there until the respond_to is evaluated. Then the POST disappears from the console. Any ideas? I’ll post the code below. TIA.
Bill
----- Controller -----
class CreateController < ApplicationController
def index end
def edit sleep(5) respond_to do |wants| wants.html { redirect_to :action => ‘wanted_html’ } wants.js { render } end end
def wanted_html end
end
----- Views -----
— index.rhtml —
Click the button to test the respond_to method
<%= form_remote_tag :url => {:action => ‘edit’} %>
— edit.rjs —
page.alert “You made it with JS turned on!”
— wanted_html.rhtml —
respond_to says you don’t have JS turned on.