I have a function named onAddressChange() which executes when a DOM ready 2 times. I don't want that because a success message that I have inserted on it should appear only when the function is triggered after a customer clicks on the change.
Is there any way to avoid entering this function after the DOM was initialized or something like that? I do not want the success message to appear the first time the page loads.
define([
'jquery',
'Magento_Checkout/js/action/select-billing-address',
'mage/translate'
], function($, selectBillingAddress, $t) {
'use strict';
return function(Component) {
return Component.extend({
onAddressChange: function(address) {
this._super();
// showing succes message
let messageSucces = $t('Your billing address has been updated');
setTimeout(function() {
$('.checkout-billing-address .billing-address-details').after('<div class="billing-address-msg">' + messageSucces + '</div>');
}, 1000)
}
});
}
});
in other expression, how to make this code not working on the first twoo times for example