Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm converting our Rails 3 web app to use jQuery mobile, and I'm having problems with "remote" links.

I have the following link:

= link_to "Text", foo_url, :method => :put, :remote => true

Which, on the server, I'm handling like this:

respond_to do |format|
  if foo.save
    format.html { redirect_back_or_to blah_url }
    format.json { render :json => {:status => "ok"} }
  end
end

This used to work wonderfully. However, since I've added jQuery Mobile, the controller code goes through the "html" branch instead of the "json" one, and responds with a redirect.

I've tried adding

 :data => { :ajax => "false" }

to the link, but I get the same effect.

Before jQuery Mobile, UJS was sending the request with the following accept header:

Accept:application/json, text/javascript, */*; q=0.01

while with jQuery Mobile, I'm getting this header:

Accept:*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript

I believe this change in headers is the culprit of the change in server-side behaviour. I haven't been able to debug through the client side to figure out who's doing what exactly. UJS is clearly still doing something, since I'm getting a "PUT request" of sorts, things get routed appropriately, etc, but I'm not sure what's changing the headers.

Thank you!
Daniel

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.