1
 <script type="text/javascript">
    require([ 'jquery', 'jquery/ui'], function($){ 
    $( "#checkoutnext" ).click(function() { 
        alert("Test!");
    });
 });
 </script>

I am using this code on onepagecheckout. but not working any Idea or suggestion

0

2 Answers 2

13

Use below code

<script type="text/javascript">
    require([ 'jquery', 'jquery/ui'], function($){
        $(document).on("click","#checkoutnext", function() {
            alert("Test!");
        });
    });
</script>
1
  • Grate Bro. Love it. Thanks A lot for save my time. May 28, 2018 at 7:19
1

You need to rewrite form.html knockout template of Magento_Checkout in your theme.

app\design\frontend\Vendorname\Themename\Magento_Checkout\web\template\billing-address\form.html

replace below div

<div class="billing-address-form" data-bind="fadeVisible: isAddressFormVisible">

to

<div class="billing-address-form" data-bind="fadeVisible: isAddressFormVisible, afterRender: renderedHandler">

Rewrite billing-address.js in your theme

app\design\frontend\Vendorname\Themename\Magento_Checkout\web\js\view\billing-address.js

add below function in above js file

        /**
         * after form render handler
         *
         */
        renderedHandler: function (elements, data) {
          //add your custom js code here
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.