dungbanguyen / adminlte-rails

The AdminLTE Rails gem integrates AdminLTE theme with the Rails asset pipeline
https://github.com/shine60vn/adminlte-rails
MIT License
130 stars 73 forks source link

Toggle sidebar button fails #3

Closed quangtt-rks closed 9 years ago

quangtt-rks commented 9 years ago

When I click toggle sidebar for the first time after entered URL, it works like normally. But wherener I click an item on sidebar to access other pages, this button stop working. It just add a "#" to address bar like normal a tag with href="#". Thought some JS didn't loaded. Any ideas? Thanks in advance!

Vietnamese: Nút ẩn hiện sidebar bị lỗi khi điều hướng giữa các trang bằng menu trên sidebar, khi nhập url và gõ enter thì lại bình thường, không biết có phải do lỗi đoạn JS nào đó không?

Ruby: 2.1.2 Rails: 4.1.6 Gem: adminlte-rails 1.3.3 OS: Ubuntu 14.04 Browser: Google Chrome 38

gcheema commented 9 years ago

+1

velobuff commented 9 years ago

It's probably Turbolinks and the $(document).ready() event not firing since subsequent full page loads aren't happening on <a> clicks. Remove the turbolinks gem from your Rails app by removing the gem in Gemfile, remove the 2 references in the head in layouts/application.html.erb and remove the reference to it in app/assets/javascripts/application.js

anthonyalberto commented 9 years ago

Alternatively, use https://github.com/chukcha-wtf/adminlte and you can keep using turbolinks!

quangtt-rks commented 9 years ago

Thanks bros! @velobuff 's answer is right. Thank you again!

imaginationcoder commented 8 years ago

its due to turbolinks Below is the code for fix.

   $(document).ready(function() {
        $.AdminLTE.layout.activate();
    });

   $(document).on('page:load', function() {
       var o;
       o = $.AdminLTE.options;
       if (o.sidebarPushMenu) {
           $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
       }
       $.AdminLTE.layout.activate();
    }); 
theshashiverma commented 5 years ago

@velobuff thank you so much bro