【问题标题】:Bootstrap Collapse Button does not work in Drupal引导折叠按钮在 Drupal 中不起作用
【发布时间】:2014-07-03 11:16:15
【问题描述】:

您好,我遇到了以下问题: 当我尝试在 Drupal 中使用我的引导子主题并缩小窗口时,下拉按钮照常出现。但是它不起作用。如果我点击它,什么都不会发生。有什么办法可以调试这个,以便我可以看到错误在哪里?

我已经做过的:transition.js 和 collapse.js 包括在内。 Jquery 在 1.8 上。代码似乎是正确的,但这里是示例:

我的页面.tpl.php:

<header id="navbar" role="banner" class="<?php print $navbar_classes; ?>">
  <div class="container">
    <div class="navbar-header">
      <?php if ($logo): ?>
      <a class="logo navbar-btn pull-left" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
        <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
      </a>
      <?php endif; ?>

      <?php if (!empty($site_name)): ?>
      <a class="name navbar-brand" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>"><?php print $site_name; ?></a>
      <?php endif; ?>

      <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>

    <?php if (!empty($primary_nav) || !empty($secondary_nav) || !empty($page['navigation'])): ?>
      <div class="navbar-collapse collapse">
        <nav role="navigation">
          <?php if (!empty($primary_nav)): ?>
            <?php print render($primary_nav); ?>
          <?php endif; ?>
          <?php if (!empty($secondary_nav)): ?>
            <?php print render($secondary_nav); ?>
          <?php endif; ?>
          <?php if (!empty($page['navigation'])): ?>
            <?php print render($page['navigation']); ?>
          <?php endif; ?>
        </nav>
      </div>
    <?php endif; ?>
  </div>
</header>

<div class="main-container container">

  <header role="banner" id="page-header">
    <?php if (!empty($site_slogan)): ?>
      <p class="lead"><?php print $site_slogan; ?></p>
    <?php endif; ?>

    <?php print render($page['header']); ?>
  </header> <!-- /#page-header -->

  <div class="row">

    <?php if (!empty($page['sidebar_first'])): ?>
      <aside class="col-sm-3" role="complementary">
        <?php print render($page['sidebar_first']); ?>
      </aside>  <!-- /#sidebar-first -->
    <?php endif; ?>

    <section<?php print $content_column_class; ?>>
      <?php if (!empty($page['highlighted'])): ?>
        <div class="highlighted jumbotron"><?php print render($page['highlighted']); ?></div>
      <?php endif; ?>
      <?php if (!empty($breadcrumb)): print $breadcrumb; endif;?>
      <a id="main-content"></a>
      <?php print render($title_prefix); ?>
      <?php if (!empty($title)): ?>
        <h1 class="page-header"><?php print $title; ?></h1>
      <?php endif; ?>
      <?php print render($title_suffix); ?>
      <?php print $messages; ?>
      <?php if (!empty($tabs)): ?>
        <?php print render($tabs); ?>
      <?php endif; ?>
      <?php if (!empty($page['help'])): ?>
        <?php print render($page['help']); ?>
      <?php endif; ?>
      <?php if (!empty($action_links)): ?>
        <ul class="action-links"><?php print render($action_links); ?></ul>
      <?php endif; ?>
      <?php print render($page['content']); ?>
    </section>

    <?php if (!empty($page['sidebar_second'])): ?>
      <aside class="col-sm-3" role="complementary">
        <?php print render($page['sidebar_second']); ?>
      </aside>  <!-- /#sidebar-second -->
    <?php endif; ?>

  </div>
</div>
<footer class="footer container">
  <?php print render($page['footer']); ?>
</footer>

【问题讨论】:

    标签: jquery twitter-bootstrap drupal-7 navigation togglebutton


    【解决方案1】:

    我用这种方式折叠任何东西

    <div class="active_one"><a class="capsolation_link" href="javascript:void()"><strong>Any title text</strong></a></div>
    <div class="collapsible_one" style="display: none;">any txt will be collabse</div>
    

    也通过在js文件中我设置了一个

    // collabse menu link
    jQuery('.collapsible_one').hide();
    jQuery('.collapsible_one:nth-child(2)').show();
    jQuery('.active_one').attr('href', 'javascript:void(0)');
    jQuery('.active_one a').attr('href', 'javascript:void(0)');
    jQuery('.active_one').click(function() {
         jQuery(this).next().slideToggle();
    });
    

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-23
      • 2020-06-30
      • 1970-01-01
      • 2018-03-16
      • 2016-12-13
      • 1970-01-01
      • 2015-01-02
      相关资源
      最近更新 更多