Search code examples
javascriptturbolinksadminlte

How to fix body height for AdminLTE 2.4.0 and turbolinks 5


I'm trying to setup AdminLTE there for my admin app and everything goes well except of content resize after navigating between views.

This happens because turbolinks prevents page reload and events like window.onResize (or whatever) doesn't called. If I manually resize window, height will be fixed.

I've founded solution here -> https://github.com/almasaeed2010/AdminLTE/issues/563#issuecomment-242715795 , but it doesn't work because $.AdminLTE is undefined.

I've looked into AdminLTE sources, but unfortunately my javascript skills are not good enough to look up for proper code so I'm wondering what to use instead of $.AdminLTE.


Solution

  • Here the answer from project maintainer — https://github.com/almasaeed2010/AdminLTE/issues/1667

    var ready = function () {
        return $(window).trigger('resize');
    };
    document.addEventListener('turbolinks:load', ready);
    

    I believe this should work in the future versions also, when some of code responsible for resizing/fixing layouts will be changed.