0

My custom module:

app\code\Zero\my_module\view\frontend\web\js\changezipcode.js

define(['jquery'], function ($) {
    'use strict';
        $(document).ready(function() 
        {
            $('#form').hide();
                 $("#changeButton").click(function() {
                     $("#form").toggle('slow');
                 });

                 $("#submit").click(function() {
                    var zipcode= $("#zipcode").val();
                    alert("Value: " + zipcode);
                });
        });
});

app\code\Zero\my_module\view\frontend\requirejs-config.js

var config = {
    map: {
        '*': {
            changezipcode:   'Zero_my_module/js/changezipcode',
        },
    }
};

Onclick event not triggered.

2 Answers 2

0

In your requirejs-config.js file add dependency of jQuery like this

var config = {
paths: {
    'changezipcode': 'Zero_my_module/js/changezipcode'
},
 shim: {
    'changezipcode': {
        deps: ['jquery']
    },
}
};

After this, when you will call changezipcode it will be dependent on jquery

2
0
 require([
           "jquery",
           'Zero_my_module/js/changezipcode'
       ], function ($, firebase) {
           'use strict';
       $(document).ready(function() 
       {
           $('#form').hide();
                $("#changeButton").click(function() {
                    $("#form").toggle('slow');
                });

                $("#submit").click(function() {
                   var zipcode= $("#zipcode").val();
                   alert("Value: " + zipcode);
               });
       });

3
  • implement this code Commented Feb 11, 2021 at 7:26
  • it's not working, codeshare.io/Gbxen7 any help thanks. Commented Feb 11, 2021 at 7:42
  • requirejs-config.js - justpaste.it/6eewa and Still getting issue : snipboard.io/iuMODe.jpg Commented Feb 11, 2021 at 7:46

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.