0

I made a website with jQuery and Ruby on Rails. When I load the first page it looks fine, but when I click on a link, the layout gets destroyed on the second page.

If Ajax deactivated: The layout of the second page looks like it doesn't even use JQuery Mobile anymore.

If Ajax is activated: the layout of the second page gets also destroyed. But It still has the JQuery Mobile elements. Only reloading the second page makes it show a normal layout. Image of destroyed vs normal layout

My app/assets/javascripts/application.js looks like this:

//= require jquery
//= require jquery_ujs
//= require jquery.mobile
//= require turbolinks
//= require_tree

My Link in the index.html.etb looks like this:<a href="<%=url_for welcome_user_path %>"data-role="button" data-ajax="true">Login</a>

My user.html.erb looks like this:

<div data-role="page" tabindex="0" class="ui-page ui-body-c ui-page-active" style="min-height: 1099px;">
    <div data-role="header" class="ui-header ui-bar-a" role="banner">
        <h1 class="ui-title" role="heading" aria-level="1">Benutzer</h1>
    </div><!-- /header -->
    <div data-role="content" class="ui-content" role="main">
        <div data-role="tabs" id="tabs">
            <div data-role="navbar">
                <ul>
                    <li>
                        <a href="#one" data-theme="a" data-ajax="false" class="ui-btn-active"> <img src="/assets/cocktails/Nekromane.png" style="width:100px;"> <h1>Nekromane</h1></a>
                    </li>
                </ul>
            </div><!-- /navabar -->
        </div><!-- /tabs -->
    </div><!-- /content -->
</div><!-- /page -->
Jimmy Jon
  • 5
  • 3

1 Answers1

0

I found the answer after searching for quite a while on StackOverflow: https://stackoverflow.com/a/17924845/6225473

Add this to the Gemfile:

gem 'jquery-turbolinks'

and this to your assets/javascripts/application.js file:

//= require jquery.turbolinks

and remove

//= require turbolinks

and use all links with

data-ajax="false"
Community
  • 1
  • 1
Jimmy Jon
  • 5
  • 3