Laravel背包下拉菜单问题

时间:2018-04-03 00:12:02

标签: laravel adminlte

我创建了一个包含一些链接的下拉菜单。它在桌面上正常工作,但在移动设备上有一个奇怪的问题。当我展开菜单时,它不会按下它下面的其他菜单。但是,如果我重新加载页面一次!换句话说,当我打开一个页面时,如果它没有按下它,当我刷新它时就会这样做。如果我再次尝试刷新它,那么问题又回来了,等等。 检查照片的确切问题:

Issue is shown

No issue

这是相关的(据我所知)代码:

<!-- This file is used to store sidebar items, starting with Backpack\Base 0.9.0 -->
<li><a href="{{ backpack_url('dashboard') }}"><i class="fa fa-dashboard"></i><span>{{ trans('backpack::base.dashboard') }}</span></a></li>
@if (Auth::user()->admin) 
<!-- @if(isset($company) && !Auth::user()->admin)
<li class="treeview active menu-open">
@else -->
<li class="treeview">
<!-- @endif -->
    <a href="#">
    <i class="fa fa-building"></i>
    <span>Välj ett företag</span>
    <span class="pull-right-container">
        <i class="fa fa-angle-left pull-right"></i>
    </span>
    </a>   
        <ul class="treeview-menu">    
        @foreach($allCompanies as $singleCompany)
  <!--       @if(isset($company) && $singleCompany->id == $company->id)
            <li class="active">
        @else -->
            <li>
       <!--  @endif -->
                <a href="/company/{{ $singleCompany->id }}">{{ $singleCompany->name }}</a>
            </li>
        @endforeach
        </ul>    
</li>
@endif
<!-- @if (Request::is('cp/*'))
<li class="treeview active">
@else -->
<li class="treeview">
<!-- @endif -->
    <a href="#">
    <i class="fa fa-building"></i>
    <span>Kontrollpanelen</span>
    <span class="pull-right-container">
        <i class="fa fa-angle-left pull-right"></i>
    </span>
    </a>
    <ul class="treeview-menu">
        @if (Auth::user()->admin) 
         <!--    @if (Request::is('cp/addcompanyview'))           
            <li class="active">
            @else -->
            <li>
            <!-- @endif  -->               
            <a class="btn btn-primary btn-block" href="/cp/addcompanyview" role="button">
                Lägg till företag
                </a>
            </li>
     <!--        @if (Request::is('cp/adduserview'))           
            <li class="active">
            @else -->
            <li>
           <!--  @endif  --> 
            <a class="btn btn-primary btn-block" href="/cp/adduserview" role="button">
                Lägg till handläggare
            </a></li>
        <!--     @if (Request::is('cp/user/*') || Request::is('cp/user'))           
            <li class="active">
            @else -->
            <li>
           <!--  @endif  --> 
            <a class="btn btn-primary btn-block" href="/cp/user" role="button">
                Hantera handläggare
            </a></li>
    <!--         @if (Request::is('cp/managecompaniesview'))           
            <li class="active">
            @else -->
            <li>
            <!-- @endif   -->
            <a class="btn btn-primary btn-block" href="/cp/managecompaniesview" role="button">
                Hantera företag
            </a></li>        
        <!-- @endif -->
  <!--       @if (Request::is('cp/manageclientsview'))           
        <li class="active">
        @else  -->
        <li>
     <!--    @endif  --> 
        <a class="btn btn-primary btn-block" href="/cp/manageclientsview" role="button">
              Hantera kunder
        </a></li>   
    </ul>
</li>
@if (Auth::user()->admin)    
<li><a href="{{ url(config('backpack.base.route_prefix', '').'/backup') }}"><i class="fa fa-hdd-o"></i> <span>Backups</span></a></li>
@endif

1 个答案:

答案 0 :(得分:0)

问题确实与JS有关,它是背包的补充,而不是AdminLTE。

此代码导致会话变量被保存,在刷新时“忘记”导致主题出现问题:

/* Store sidebar state */
/*         $('.sidebar-toggle').click(function(event) {
          event.preventDefault();
          if (Boolean(sessionStorage.getItem('sidebar-toggle-collapsed'))) {
            sessionStorage.setItem('sidebar-toggle-collapsed', '');
          } else {
            sessionStorage.setItem('sidebar-toggle-collapsed', '1');
          }
        });

我评论了它,问题就消失了。

PS:此代码位于背包默认主题的layout.blade.php中。