【问题标题】:increment button not working properly in magento增量按钮在magento中无法正常工作
【发布时间】:2015-06-23 00:03:32
【问题描述】:

我正在使用 magento 1.8.1 并且我更改了增量减量脚本。随着那里设计的变化。

jQuery(function() {

    jQuery("div.add-to-cart .qty_pan").append('<div class="inc add">&#8250;</div><div class="dec add">&#8249;</div>');

    jQuery("#plus, #minus").click(function(){
      
        var jQueryadd = jQuery(this);
        var oldValue = jQueryadd.parent().find("input").val();
		var newVal = 0;
    
        if (jQueryadd.text() == "+") {
    	   newVal = parseFloat(oldValue) + 1;
    	  // AJAX save would go here
    	} else {
    	  // Don't allow decrementing below zero
    	  if (oldValue > 1) {
    	      newVal = parseFloat(oldValue) - 1;
    	      // AJAX save would go here
    	  }
		  if(oldValue == 1){
			  newVal = parseFloat(oldValue);
			  }
    	}
    	jQueryadd.parent().find("input").val(newVal);
    });
  
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
		<button id="plus" class="btnplus">+</button>
		<div class="qty_pan">
				<input type="text" min="1" max="1000" name="qty" id="qty" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
		</div>
		<button id="minus" class="btnminus">-</button>

现在的问题是,当我单击加号按钮或减号按钮时,数量会发生变化,但它会直接进入购物车页面。我不知道如何用那个购物车页面链接。所以请帮助我。

see here on my website

【问题讨论】:

  • 不好意思是加减后页面重定向的问题?我有点困惑

标签: javascript php jquery magento magento-1.8


【解决方案1】:

您可以尝试通过调用preventDefault() 来禁用按钮的默认行为。

jQuery("#plus, #minus").click(function(event){
    event.preventDefault();
    //Your code
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    • 2020-10-08
    相关资源
    最近更新 更多