使用引导切换侧边栏菜单的问题
Issues in toggle sidebar menu with bootstrap
我正在使用shopify网站,在该侧边栏菜单中,需要像这样的工作 链接 http://jsfiddle.net/wasimkazi/CGsJH/2/
我的意思是,当单击一个链接时,应该隐藏另一个链接(如果此链接打开
)。这是使用的引导程序:
!function ($) {
"use strict"; // jshint ;_;
/* COLLAPSE PUBLIC CLASS DEFINITION
* ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.collapse.defaults, options)
if (this.options.parent) {
this.$parent = $(this.options.parent)
}
this.options.toggle && this.toggle()
}
Collapse.prototype = {
constructor: Collapse
, dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
, show: function () {
var dimension
, scroll
, actives
, hasData
if (this.transitioning) return
dimension = this.dimension()
scroll = $.camelCase(['scroll', dimension].join('-'))
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) {
hasData = actives.data('collapse')
if (hasData && hasData.transitioning) return
actives.collapse('hide')
hasData || actives.data('collapse', null)
}
this.$element[dimension](0)
this.transition('addClass', $.Event('show'), 'shown')
$.support.transition && this.$element[dimension](this.$element[0][scroll])
}
, hide: function () {
var dimension
if (this.transitioning) return
dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide'), 'hidden')
this.$element[dimension](0)
}
, reset: function (size) {
var dimension = this.dimension()
this.$element
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
return this
}
, transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
if (startEvent.type == 'show') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1
this.$element[method]('in')
$.support.transition && this.$element.hasClass('collapse') ?
this.$element.one($.support.transition.end, complete) :
complete()
}
, toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
/* COLLAPSIBLE PLUGIN DEFINITION
* ============================== */
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
, options = typeof option == 'object' && option
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.collapse.defaults = {
toggle: true
}
$.fn.collapse.Constructor = Collapse
/* COLLAPSIBLE DATA-API
* ==================== */
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var $this = $(this), href
, target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^'s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data()
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$(target).collapse(option)
})
}(window.jQuery);
由于您无法修改 HTML 以使其成为手风琴,因此可以使用 show 事件进行折叠并隐藏已显示的部分。
$(document).ready(function () {
$('.collapse').on('show.bs.collapse', function () {
$('.collapse.in').collapse('hide');
})
})
见小提琴
相关文章:
- 在上下文菜单项单击上显示侧边栏/弹出窗口的最佳方法是什么
- ExtJS 4.1.它们是创建侧边栏菜单的最佳组件(如左面板中的Worpress)
- 可折叠侧边栏/导航菜单
- 如何关闭侧边栏菜单?(引导程序)
- 引导折叠侧边栏菜单到下拉菜单
- 如何侧边栏菜单
- 侧边栏子菜单元素未按预期显示/隐藏
- 使用引导切换侧边栏菜单的问题
- 具有多个操作的侧边栏菜单
- 如何将此SVG“侧边栏菜单”放在右侧
- 我需要 JavaScript 作为我的侧边栏菜单活动类在 codeigniter 中
- 如何用Bootstrap获得一个漂亮的可折叠侧边栏菜单(另一个帖子)
- 防止侧边栏菜单在页脚下方滚动
- ie9及以下版本显示滑出侧边栏菜单时的问题
- 需要一个“查看更多”样式侧边栏菜单在Jquery
- 显示/隐藏侧边栏菜单和扩展颜色大小与幻灯片效果
- 如何在单击时突出显示侧边栏菜单
- 使用Rails 4,需要帮助来制作一个更好的侧边栏菜单用于导航
- 响应侧边栏菜单和网页
- 我如何结合一个引导旋转木马与侧边栏菜单