jQuery-如何禁用展开的.item中的可单击内容?
我正在使用jquery创建一个公文包库,几乎所有的东西都按预期工作。我唯一想改变的是打开内容的行为。现在,当您单击照片时,内容框会展开并显示一个较大的带有一些文本的图像,问题是当您再次单击内容框(.item)时,内容会恢复到原始大小,我不希望这样,因为某些框包含多个带有颜色框的图像 最好的解决方案是在“大”容器上添加一个关闭按钮,而不是使用整个盒子区域,但事实证明这超出了我的能力 下面是我用来控制框大小和单击检测的代码:jQuery-如何禁用展开的.item中的可单击内容?,jquery,jquery-isotope,Jquery,Jquery Isotope,我正在使用jquery创建一个公文包库,几乎所有的东西都按预期工作。我唯一想改变的是打开内容的行为。现在,当您单击照片时,内容框会展开并显示一个较大的带有一些文本的图像,问题是当您再次单击内容框(.item)时,内容会恢复到原始大小,我不希望这样,因为某些框包含多个带有颜色框的图像 最好的解决方案是在“大”容器上添加一个关闭按钮,而不是使用整个盒子区域,但事实证明这超出了我的能力 下面是我用来控制框大小和单击检测的代码: $(function() { var $containe
$(function() {
var $container = $('#pageWrapper'),
$items = $('.item');
$('#filter').find('a').click(function() {
// get the href attribute
var filterName = '.' + $(this).attr('href').slice(1);
filterName = filterName === '.show-all' ? '*' : filterName;
$container.isotope({
filter: filterName
});
return false;
});
// change size of clicked element
$container.find('.item').live('click', function() {
if ($(this).is('.large')) {
jQuery('.item-content', this).fadeToggle("fast", "linear");
jQuery('.thumb', this).fadeToggle("fast", "linear");
jQuery('h3', this).fadeToggle("fast", "linear");
$(this).toggleClass('large');
$container.isotope('reLayout');
} else {
jQuery('.large > .item-content');
jQuery('.large > .thumb');
jQuery('.large > h3');
$container.find('.large').removeClass('large');
jQuery('.item-content', this).fadeToggle("fast", "linear");
jQuery('.thumb', this).fadeToggle("fast", "linear");
jQuery('h3', this).fadeToggle("fast", "linear");
$(this).toggleClass('large');
$container.isotope('reLayout');
}
});
// switch selected class on buttons
$('#categories').find('.option-set a').click(function() {
var $this = $(this);
// don't proceed if already selected
if (!$this.hasClass('selected')) {
$this.parents('.option-set').find('.selected').removeClass('selected');
$this.addClass('selected');
}
});
// isotope behavior
$container.isotope({
itemSelector: '.item',
masonry: {
columnWidth: 10
},
你知道我怎样才能在单击时阻止“大”框关闭,并添加一个按钮来关闭它而不是整个框吗
提前谢谢 好吧,我终于成功了,所以我将分享我对代码所做的更改;也许不是最好的,但它奏效了。它可能对某人有用,所以给你 这段代码将盒子缩小到原来的大小:
if ($(this).is('.large')) {
jQuery('.item-content', this).fadeToggle("fast", "linear");
jQuery('.thumb', this).fadeToggle("fast", "linear");
jQuery('h3', this).fadeToggle("fast", "linear");
$(this).toggleClass('large');
$container.isotope('reLayout');
经过几天的努力之后,我更改了以下代码:
if ($(this).is('.large')) {
jQuerycontainer.find('.large').each(function(){
jQuery(this).toggleClass('large'); });
现在,一旦.item扩展到.item.large,它将不会调整大小,直到您单击另一个.item,无论您单击大框多少次,它都将保持不变!因此,现在我可以在一个盒子中添加多个图像,并使用Lightbox或Colorbox打开它们,而无需我的同位素。item.large缩小!:我认为一个好的解决办法是。基本上,你可以使每个同位素元素内部的任何div成为可点击的“最大化”或“最小化”元素;比如按钮、区域、图标、链接等等。而且,您不必担心会干扰诸如event.stopPropagation()之类的jQuery方法。的可能重复