我添加到我的product-list.tpl輸入與+/-按鈕的作品,直到我使用任何過濾器從塊層模塊,然後+/-按鈕停止工作。PrestaShop自定義輸入塊的問題
我的輸入是這樣的:
<input type='button' value='-' class='qtymin' field='qty' />
<input type="text" class='qtynum' name="qty" id="quantity_to_cart_{$product.id_product|intval}" value="1"/>
<input type='button' value='+' class='qtypl' field='qty' />
JS代碼是:
jQuery(document).ready(function(){
// This button will increment the value
$('.qtyplus').click(function(e){
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If is not undefined
if (!isNaN(currentVal)) {
// Increment
$('input[name='+fieldName+']').val(currentVal + 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
// This button will decrement the value till 0
$(".qtyminus").click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('field');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0) {
// Decrement one
$('input[name='+fieldName+']').val(currentVal - 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(0);
}
});
});
Blocklayered V2.2.0的Prestashop v1.6.1.8
任何想法,爲什麼這不工作?
你有沒有試着用$( 'parent_class')上( '點擊', 'qtyminus',功能.... –
很抱歉,但我。不知道該怎麼做,我有編程的基本知識。Colud你給我一個樣本或寫更多關於它的東西? –