Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
how to make a js code not working on the first twoo times

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!