让Magento 1.9产品过滤器可折叠
问题描述:
我正在尝试使可折叠Mgento商店的产品过滤器。我尝试编辑template/category/layer/view.phtml中的view.phtml,但它不工作。让Magento 1.9产品过滤器可折叠
我编辑了这些线:<dt><?php echo $this->__($_filter->getName()) ?></dt>
到<dt><a href="/"><?php echo $this->__($_filter->getName()) ?></a></dt>
,我加入了一些jQuery的是这样的:
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("dl#narrow-by-list> dd:not(:first)").hide();
jQuery("dl#narrow-by-list> dt a").click(function(){
jQuery("dl#narrow-by-list> dd:visible").slideUp("fast");
jQuery(this).parent().next().slideDown("fast");
return false;
});
});
/* ]]> */
</script>
当前代码:
?>
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
</div>
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if ($this->getLayer()->getState()->getFilters()): ?>
<div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
<?php endif; ?>
<?php if($this->canShowOptions()): ?>
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<div class="<?php if(strcasecmp($_filter->getName(), 'PRICE') == 0) echo 'layered-price'; else echo 'layered-attribute'; ?>">
<div class="title-layered"><dt><a href="/"><?php echo $this->__($_filter->getName()) ?></a></dt></div>
<dd><?php echo $_filter->getHtml() ?></dd>
</div>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("#narrow-by-list> dd:not(:first)").hide();
jQuery("#narrow-by-list> dt a").click(function(){
jQuery("#narrow-by-list> dd:visible").slideUp("fast");
jQuery(this).parent().next().slideDown("fast");
return false;
});
});
/* ]]> */
</script>
任何人任何想法,为什么这不管用?
<dt><a href="javascript:void(0)"> <?php echo $this->__($_filter->getName()) ?></a></dt>
,然后你的jQuery单击功能将被触发像往常一样:
答
你的链接标签
你就可以欺骗这个href属性你的JavaScript进行了点击事件。
那我做我的jQuery更新到这个诀窍: “(函数($){$ (文件)。就绪(函数(){ $( “#窄通过列表DD”)。 hide(); $(“。layered-nav dt a”)。bind(“click”,function(){(this).parent()。next()。slideToggle(); return false; }) }); })(jQuery);' 我现在要做什么,只有当屏幕是一定的宽度,以便菜单项只在手机上折叠,任何想法如何做到这一点? –
如果您遇到新问题和新问题,好的行为是再次询问另一个帖子并验证当前问题。 –