Hello,
When you dynamically set a value in a textfield using jQuery .val(), you have to manually trigger the .change event if you want to add extra code that trigger when the value of the field change.
To do that, in commerce_extra_quantity.js, just change
// Set new quantity
if (new_quantity >= 1) {
$(selector).val(new_quantity);
}
By
// Set new quantity
if (new_quantity >= 1) {
$(selector).val(new_quantity).change();
}
Like that, you can use things like that in your own custom code for extra customization :
$('.form-item-quantity input').change(function() {
// Some extra jquery code here
});
Without that small change, it's impossible to add extra code depending on the value change of that field (or it will trigger only if the user manually change the field, but not when he click on plus or minus buttons
Comments
Comment #1
5n00py commentedThanks for post, but its already fixed in #2313973: Commerce Extra Quantity: trigger CHANGE event
See https://www.drupal.org/commitlog/commit/30174/80213acc924588d49fdd0ea1b3...