I'm trying to trigger a second event dependent on the first like so:
...
$('#productFamilyId').val(data.contents.productfamily);
$('#productFamilyId').trigger('change', function() {
$('#productId').val(data.contents.product);
$('#productId').trigger('change');
});
It's not waiting for the first trigger to complete before attempting to trigger the second event. Is it possible to wait for the first trigger to complete?
Probably you want this:
$('#productFamilyId').trigger('change', function() {
$('#productId').val(data.contents.product);
setTimeout(function(){
$('#productId').trigger('change');
},1);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With