I am using Rails 3.2.12 and the latest jquery-mobile gem.
In the layout:
<%= javascript_include_tag "mobile" %>
In mobile.js:
//= require jquery
//= require jquery_ujs
//= require jquery.mobile
Now whenever I manually load a page by typing the full URL, everything seems to work as it should. However, when I click on a link or submit a form, there is a strange "double submission" happening.
Here's an example of the server console when logging in:
Submit the login form
Started POST "/login/signin?class=form" for 127.0.0.1 at 2014-02-10 11:21:58 +0100 Processing by LoginController#signin as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"0LlkpMMR8/4HMgzlWob15TSxvNvCIPUaW0Zuutygos8=", "email"=>"director@demo.foot", "password"=>"[FILTERED]", "connect"=>"Sign in", "class"=>"form"}
After processing the signin, the request gets redirected to home/myome as it should
Started GET "/home/myhome" for 127.0.0.1 at 2014-02-10 11:21:58 +0100 Processing by HomeController#myhome as HTML
Now this is when the weird stuff happens, as a GET method is fired out of nowhere
Started GET "/login/signin?class=form" for 127.0.0.1 at 2014-02-10 11:22:00 +0100 Processing by LoginController#signin as */*
Followed by:
Started GET "/home" for 127.0.0.1 at 2014-02-10 11:22:00 +0100 Processing by HomeController#index as */*
Similarily, clicking on simple links fires two identical GET requests.
When I disable ajax with ajaxEnabled = false
, the links are working.
One explanation could be including jquery twice somehow but I cannot figure out when and how. I have seen a couple of similar threads such as this one and have made sure not to precompile assets in development mode, but to no avail.
edit: I gave up on this a while ago when I realised that all the ids, throughout the site's pages needed to be unique in order to use jquery mobile's Ajax loading abilities. This was where my issues were coming from.
Since I am applying jquery mobile to an existing large website, with lots of forms and manually set ids, I have chosen to keep it simple for now and disable Ajax.
Building from scratch, one would have to come up with a good system to ensure unique ids throughout the site.
Here's a link with some advice on this subject: http://metaskills.net/2011/08/24/jquery-mobile-and-rails/