opencart价格范围滑块扩展

时间:2016-03-09 11:05:41

标签: javascript php jquery module

请帮我纠正代码。与其他javascript操作冲突的地方。 opencart中的此价格过滤器正在停止在类别页面中添加到购物车的操作。以下是在javascript中调用php的代码。缺少某些东西或没有正确编码。

<div class="row">
    <div class="slide-filter">
        <h2><?php echo $heading_title; ?></h2>
        <div class="list-group">
            <div class="list-group-item">
                <div id="filter-group1">
                    <div id="scale-slider"></div>
                    <button type="button" id="button-price-filter" class="filter-button"><?php echo $button_filter; ?></button>
                </div>
            </div>
        </div>
    </div>
</div>

和javascript是

$("#scale-slider")
    .slider({ 
        min: <?php echo round($price_range_min) ; ?>, 
        max: <?php echo round($price_range_max) ; ?>, 
        range: true, 
        values: [<?php echo (isset($price_range[0])?$price_range[0]:0); ?>, <?php echo (isset($price_range[1])?$price_range[1]:$price_range_max); ?>] 
    })

    .slider("pips", {
        rest: false,
        <?php if (!$right_code) { ?>
        prefix: "<?php echo $price_code; ?>",
        <?php } else { ?>
        suffix: "<?php echo $price_code; ?>"
        <?php } ?>
    })

    .slider("float");
    (function( $ ) {
        $(function() {
            $('#button-price-filter').on('click', function() {
                priceRange = [];
                $('#scale-slider .ui-slider-tip').each(function(){
                    priceRange.push($(this).html());
                });
                $('.<?php echo $product_class; ?>').hide();
                $('.clearfix').remove();
                $('.<?php echo $product_class; ?>').each(function(){
                if( $(this).find( ".price span.price-new" ).length ) {
                    var price = $(this).find( ".price span.price-new" ).html().replace('<?php echo $price_code; ?>','').replace(',','');
                } else {
                    var text = $(this).find('.price').html().replace('<?php echo $price_code; ?>','');
                if( $(this).find( ".price span" ).length ) {
                    var price = text.substring(0,text.indexOf('<span')).replace(',','');
                } else {
                    var price = text.replace(',','');
                }
            }   
            price = parseInt(price);
            if( !isNaN(price) && (price > priceRange[0] && price < priceRange[1]) ){
                $(this).fadeIn("slow");
            }
        });
    });
  });
})(jQuery);

1 个答案:

答案 0 :(得分:0)

删除$(&#39; .clearfix&#39;)。remove(); ,可能是完美的工作

相关问题