javascript - PrestaShop Blocklayered issue with custom input -


i add product-list.tpl input +/- buttons works until use filter blocklayered module, +/- buttons stop working.

my input looks like:

<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 code is:

jquery(document).ready(function(){         // button increment value         $('.qtyplus').click(function(e){             // stop acting button             e.preventdefault();             // field name             fieldname = $(this).attr('field');             // current value             var currentval = parseint($('input[name='+fieldname+']').val());             // if not undefined             if (!isnan(currentval)) {                 // increment                 $('input[name='+fieldname+']').val(currentval + 1);             } else {                 // otherwise put 0 there                 $('input[name='+fieldname+']').val(0);             }         });         // button decrement value till 0         $(".qtyminus").click(function(e) {             // stop acting button             e.preventdefault();             // field name             fieldname = $(this).attr('field');             // current value             var currentval = parseint($('input[name='+fieldname+']').val());             // if isn't undefined or greater 0             if (!isnan(currentval) && currentval > 0) {                 // decrement 1                 $('input[name='+fieldname+']').val(currentval - 1);             } else {                 // otherwise put 0 there                 $('input[name='+fieldname+']').val(0);             }         });     }); 

blocklayered v2.2.0 prestashop v1.6.1.8

any ideas why doesn't work?

try attach event document:

    jquery(document).ready(function(){         // button increment value         $(document).on('click', '.qtyplus', function(e){             // stop acting button             e.preventdefault();             // field name             fieldname = $(this).attr('field');             // current value             var currentval = parseint($('input[name='+fieldname+']').val());             // if not undefined             if (!isnan(currentval)) {                 // increment                 $('input[name='+fieldname+']').val(currentval + 1);             } else {                 // otherwise put 0 there                 $('input[name='+fieldname+']').val(0);             }         });         // button decrement value till 0         $(document).on('click', '.qtyminus', function(e) {             // stop acting button             e.preventdefault();             // field name             fieldname = $(this).attr('field');             // current value             var currentval = parseint($('input[name='+fieldname+']').val());             // if isn't undefined or greater 0             if (!isnan(currentval) && currentval > 0) {                 // decrement 1                 $('input[name='+fieldname+']').val(currentval - 1);             } else {                 // otherwise put 0 there                 $('input[name='+fieldname+']').val(0);             }         });     }); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -