0

这曾经与我的旧导航一起使用,但现在不使用引导程序。我已经看到 .nav a 的 javascript 解决方案,但我不能有链接,因为我使用 javascript 将页面加载到主容器中。我这里有什么选择吗?谢谢

<ul class="nav">
          <li class="active" id="changetohome"><a style="cursor:pointer" id="changetohome"><i class="icon-home"></i> Home</a></li>
          <li class="none" id="changetodiscover"><a style="cursor:pointer" id="changetodiscover"><i class="icon-home"></i> Explore</a></li>
</ul>

$('#changetohome').click(function () {
      $('#loadingAjaxs').show(); $('#flubestext').hide();
      $('#contentwrap').load('@Url.Action("FollowingDetail", "Following", new {@ajax = "yes"})', function () {
          $('#loadingAjaxs').hide(); $('#flubestext').show(); window.history.pushState({ "page": "home" }, 'title1', '/'); $(window).scrollTop(0);
          document.getElementById("changetohome").className = "active"; 
          document.getElementById("changetodiscover").className = "none";
      })
   });

$('#changetodiscover').click(function () {
        $('#loadingAjaxs').show(); $('#flubestext').hide();
        $('#contentwrap').load('@Url.Action("TagPageDetail", "TagPage", new {@page = 0, @ajax = "yes"})', function () {
            $('#loadingAjaxs').hide(); $('#flubestext').show(); window.history.pushState({ "page": "discover" }, 'title', '/discover'); $(window).scrollTop(0);
            document.getElementById("changetohome").className = "none"; 
            document.getElementById("changetodiscover").className = "active";
        })
     });
4

1 回答 1

0

Bootstrap3 changes navigation by swapping the class names navbar and collapse.

<nav class="navbar navbar-default" role="navigation">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

I think my situation was somewhat different from yours however, I was able to load different menus by modifying this script below in a myBootstrap.js

this.$element
      .removeClass('collapse')
      .addClass('collapsing')
      [dimension](0)

    this.transitioning = 1

    var complete = function () {
      this.$element
        .removeClass('collapsing')
        .addClass('in')
        [dimension]('auto')
      this.transitioning = 0
      this.$element.trigger('shown.bs.collapse')
    }

    if (!$.support.transition) return complete.call(this)

    var scrollSize = $.camelCase(['scroll', dimension].join('-'))

    this.$element
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
      [dimension](this.$element[0][scrollSize])
  }

  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return

    var startEvent = $.Event('hide.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

    var dimension = this.dimension()

    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight

    this.$element
      .addClass('collapsing')
      .removeClass('collapse')
      .removeClass('in')

    this.transitioning = 1

    var complete = function () {
      this.transitioning = 0
      this.$element
        .trigger('hidden.bs.collapse')
        .removeClass('collapsing')
        .addClass('collapse')
于 2013-11-10T18:53:12.740 回答