Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout Boxed bug when resize page #1042

Closed
EdisonHarada opened this issue May 10, 2016 · 2 comments
Closed

Layout Boxed bug when resize page #1042

EdisonHarada opened this issue May 10, 2016 · 2 comments

Comments

@EdisonHarada
Copy link

When you use layout-boxed much times it gives an error of jQuery, because the _fix function in $.AdminLTE.controlSidebar, delegate itself to the resize method of page when it's layout-boxed, so after some resizing it turn to like 2k calls of the same method.

$.AdminLTE.controlSidebar = {

..................................................

_fix: function (sidebar) {
      var _this = this;
      if ($("body").hasClass('layout-boxed')) {
        sidebar.css('position', 'absolute');
        sidebar.height($(".wrapper").height());
        $(window).resize(function () {
          _this._fix(sidebar);
        });
      } else {
        sidebar.css({
          'position': 'fixed',
          'height': 'auto'
        });
      }
    }

............................

}

So resolving it, you remove the delegate of resize to the activate part:

 $.AdminLTE.controlSidebar = {
//instantiate the object
    activate: function () {
      //Get the object
      var _this = this;
      //Update options
      var o = $.AdminLTE.options.controlSidebarOptions;
      //Get the sidebar
      var sidebar = $(o.selector);
      //The toggle button
      var btn = $(o.toggleBtnSelector);

      //Listen to the click event
      btn.on('click', function (e) {
        e.preventDefault();
        //If the sidebar is not open
        if (!sidebar.hasClass('control-sidebar-open')
            && !$('body').hasClass('control-sidebar-open')) {
          //Open the sidebar
          _this.open(sidebar, o.slide);
        } else {
          _this.close(sidebar, o.slide);
        }
      });

      //If the body has a boxed layout, fix the sidebar bg position
      var bg = $(".control-sidebar-bg");
      _this._fix(bg);

      //If the body has a fixed layout, make the control sidebar fixed
      if ($('body').hasClass('fixed')) {
        _this._fixForFixed(sidebar);
      } else {
        //If the content height is less than the sidebar's height, force max height
        if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
          _this._fixForContent(sidebar);
        }
      }
        $(window).resize(function () {
          _this._fix(sidebar);
        });
    },
.....................
 _fix: function (sidebar) {
      if ($("body").hasClass('layout-boxed')) {
        sidebar.css('position', 'absolute');
        sidebar.height($(".wrapper").height());
      } else {
        sidebar.css({
          'position': 'fixed',
          'height': 'auto'
        });
      }
    }
............................
}
@kspearrin
Copy link

This is discussed here: #683

@almasaeed2010
Copy link
Contributor

Due to some neglect in my part, many issues weren't addressed for some time. Some of these issues are no longer relevant since a solution might have been found. Therefore, we decided to close all issues that are over a month old. However, if the issue still persists and you'd like help, then by all means repost your issue and we will consider it again. In the mean time, we will close this post.

Thanks for your understanding and we apologize for any inconvenience <3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants