How to add custom JS in admin Magento 2Magento 2 does not read my requirejs-config.jsMagento 2: can't use materialize.js on my custom moduleRequire Js Error: Mismatched anonymous define() module: function Magento 2Magento 2: Not Able to Login As A CustomerMagento 2 add custom validation ruleImportExport module: can't work custom file adapter in magento2?Magento2 Autoload errorMagento 2 override admin product-gallery.js file in custom moduleAdd popup on clicking custom button in product edit page in admin in magento 2.3How implement form in payment method

Why is there a large performance impact when looping over an array over 240 elements?

These were just lying around

When were the tantalum capacitors first used in computing?

Why I have higher ping to the VLAN interface than to other local interfaces

How to disable "Completion time:..." in SQL Server Messages window

Can a PC use the Levitate spell to avoid movement speed reduction from exhaustion?

Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?

On the Rømer experiments and the speed of light

Solution to German Tank Problem

What is the status of the F-1B engine development?

Can the government force you to change your license plate?

The cat ate your input again!

Does the Fireball spell damage objects?

Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?

Plotting octahedron inside the sphere and sphere inside the cube

Generate Brainfuck for the numbers 1–255

How to reduce Sinas Chinam

Normalization constant of a planar wave

80's/90's superhero cartoon with a man on fire and a man who made ice runways like Frozone

Why does chown not work in RUN command in Docker?

How to describe accents?

Enigma between Collegues (Part1)

What ability do tools use?

Why does the standard fingering / strumming for a D maj chord leave out the 5th string?



How to add custom JS in admin Magento 2


Magento 2 does not read my requirejs-config.jsMagento 2: can't use materialize.js on my custom moduleRequire Js Error: Mismatched anonymous define() module: function Magento 2Magento 2: Not Able to Login As A CustomerMagento 2 add custom validation ruleImportExport module: can't work custom file adapter in magento2?Magento2 Autoload errorMagento 2 override admin product-gallery.js file in custom moduleAdd popup on clicking custom button in product edit page in admin in magento 2.3How implement form in payment method






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to add a custom js file in magento 2 in the admin but all I can see are sample on how to add in the frontend. I found some that shows how to add in admin but none works. Below are my code that I copied from some sources



//app/code/COMPANY/PRODUCT/view/adminhtml/requirejs-config.js
var config =
"map":
"*":
"generateMenu": "TCM_HeaderMenu/js/generateMenu"





and in the file located in app/code/COMPANY/PRODUCT/view/adminhtml/web/js/generateMenu.js



 /**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
require([
'jquery',
'logger'

], function($, logger)
'use strict';
logger.log('inchoo.js is loaded!!');

//creating jquery widget
$.widget('generateMenu.js',
_create: function()

this.element.on('click', function(e)
logger.log("You click on element: " + e.target);
);


);

return $.generateMenu.js;
);


But it seems that this is not being called when I refresh the page.



Note: I'm trying to load the custom js in Catalog->category page in the admin panel










share|improve this question
































    1















    I'm trying to add a custom js file in magento 2 in the admin but all I can see are sample on how to add in the frontend. I found some that shows how to add in admin but none works. Below are my code that I copied from some sources



    //app/code/COMPANY/PRODUCT/view/adminhtml/requirejs-config.js
    var config =
    "map":
    "*":
    "generateMenu": "TCM_HeaderMenu/js/generateMenu"





    and in the file located in app/code/COMPANY/PRODUCT/view/adminhtml/web/js/generateMenu.js



     /**
    * Copyright © Magento, Inc. All rights reserved.
    * See COPYING.txt for license details.
    */
    require([
    'jquery',
    'logger'

    ], function($, logger)
    'use strict';
    logger.log('inchoo.js is loaded!!');

    //creating jquery widget
    $.widget('generateMenu.js',
    _create: function()

    this.element.on('click', function(e)
    logger.log("You click on element: " + e.target);
    );


    );

    return $.generateMenu.js;
    );


    But it seems that this is not being called when I refresh the page.



    Note: I'm trying to load the custom js in Catalog->category page in the admin panel










    share|improve this question




























      1












      1








      1








      I'm trying to add a custom js file in magento 2 in the admin but all I can see are sample on how to add in the frontend. I found some that shows how to add in admin but none works. Below are my code that I copied from some sources



      //app/code/COMPANY/PRODUCT/view/adminhtml/requirejs-config.js
      var config =
      "map":
      "*":
      "generateMenu": "TCM_HeaderMenu/js/generateMenu"





      and in the file located in app/code/COMPANY/PRODUCT/view/adminhtml/web/js/generateMenu.js



       /**
      * Copyright © Magento, Inc. All rights reserved.
      * See COPYING.txt for license details.
      */
      require([
      'jquery',
      'logger'

      ], function($, logger)
      'use strict';
      logger.log('inchoo.js is loaded!!');

      //creating jquery widget
      $.widget('generateMenu.js',
      _create: function()

      this.element.on('click', function(e)
      logger.log("You click on element: " + e.target);
      );


      );

      return $.generateMenu.js;
      );


      But it seems that this is not being called when I refresh the page.



      Note: I'm trying to load the custom js in Catalog->category page in the admin panel










      share|improve this question
















      I'm trying to add a custom js file in magento 2 in the admin but all I can see are sample on how to add in the frontend. I found some that shows how to add in admin but none works. Below are my code that I copied from some sources



      //app/code/COMPANY/PRODUCT/view/adminhtml/requirejs-config.js
      var config =
      "map":
      "*":
      "generateMenu": "TCM_HeaderMenu/js/generateMenu"





      and in the file located in app/code/COMPANY/PRODUCT/view/adminhtml/web/js/generateMenu.js



       /**
      * Copyright © Magento, Inc. All rights reserved.
      * See COPYING.txt for license details.
      */
      require([
      'jquery',
      'logger'

      ], function($, logger)
      'use strict';
      logger.log('inchoo.js is loaded!!');

      //creating jquery widget
      $.widget('generateMenu.js',
      _create: function()

      this.element.on('click', function(e)
      logger.log("You click on element: " + e.target);
      );


      );

      return $.generateMenu.js;
      );


      But it seems that this is not being called when I refresh the page.



      Note: I'm trying to load the custom js in Catalog->category page in the admin panel







      magento2 magento-2.1 magento2.3 requirejs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 1 at 12:04









      Mohit Rane

      1,20718 bronze badges




      1,20718 bronze badges










      asked Aug 1 at 11:45









      MadzQuestioningMadzQuestioning

      2709 bronze badges




      2709 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          1














          Try :




          app/code/Company/Product/view/adminhtml/requirejs-config.js




          var config = 

          deps: [
          "Company_Product/js/generateMenu"
          ]

          ;



          app/code/Company/Product/view/adminhtml/web/js/generateMenu.js




          define(["jquery"], function($) 
          "use strict";
          //Your code here
          );



          clean cache



          clean var/view_preprocessed content



          clean pub/static content



          deploy the static content : php bin/magento
          setup:static-content:deploy -f







          share|improve this answer






















          • 1





            You're the star thanks a lot you saved me been looking for this answer for hours now

            – MadzQuestioning
            Aug 1 at 13:11


















          0














          please try with below code :



          var config = 
          map:
          '*':
          generateMenu:'TCM_HeaderMenu::js/generateMenu'


          ;


          i hope its work for you






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f284085%2fhow-to-add-custom-js-in-admin-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Try :




            app/code/Company/Product/view/adminhtml/requirejs-config.js




            var config = 

            deps: [
            "Company_Product/js/generateMenu"
            ]

            ;



            app/code/Company/Product/view/adminhtml/web/js/generateMenu.js




            define(["jquery"], function($) 
            "use strict";
            //Your code here
            );



            clean cache



            clean var/view_preprocessed content



            clean pub/static content



            deploy the static content : php bin/magento
            setup:static-content:deploy -f







            share|improve this answer






















            • 1





              You're the star thanks a lot you saved me been looking for this answer for hours now

              – MadzQuestioning
              Aug 1 at 13:11















            1














            Try :




            app/code/Company/Product/view/adminhtml/requirejs-config.js




            var config = 

            deps: [
            "Company_Product/js/generateMenu"
            ]

            ;



            app/code/Company/Product/view/adminhtml/web/js/generateMenu.js




            define(["jquery"], function($) 
            "use strict";
            //Your code here
            );



            clean cache



            clean var/view_preprocessed content



            clean pub/static content



            deploy the static content : php bin/magento
            setup:static-content:deploy -f







            share|improve this answer






















            • 1





              You're the star thanks a lot you saved me been looking for this answer for hours now

              – MadzQuestioning
              Aug 1 at 13:11













            1












            1








            1







            Try :




            app/code/Company/Product/view/adminhtml/requirejs-config.js




            var config = 

            deps: [
            "Company_Product/js/generateMenu"
            ]

            ;



            app/code/Company/Product/view/adminhtml/web/js/generateMenu.js




            define(["jquery"], function($) 
            "use strict";
            //Your code here
            );



            clean cache



            clean var/view_preprocessed content



            clean pub/static content



            deploy the static content : php bin/magento
            setup:static-content:deploy -f







            share|improve this answer















            Try :




            app/code/Company/Product/view/adminhtml/requirejs-config.js




            var config = 

            deps: [
            "Company_Product/js/generateMenu"
            ]

            ;



            app/code/Company/Product/view/adminhtml/web/js/generateMenu.js




            define(["jquery"], function($) 
            "use strict";
            //Your code here
            );



            clean cache



            clean var/view_preprocessed content



            clean pub/static content



            deploy the static content : php bin/magento
            setup:static-content:deploy -f








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 1 at 12:49

























            answered Aug 1 at 12:28









            PЯINCƏPЯINCƏ

            8,7023 gold badges11 silver badges50 bronze badges




            8,7023 gold badges11 silver badges50 bronze badges










            • 1





              You're the star thanks a lot you saved me been looking for this answer for hours now

              – MadzQuestioning
              Aug 1 at 13:11












            • 1





              You're the star thanks a lot you saved me been looking for this answer for hours now

              – MadzQuestioning
              Aug 1 at 13:11







            1




            1





            You're the star thanks a lot you saved me been looking for this answer for hours now

            – MadzQuestioning
            Aug 1 at 13:11





            You're the star thanks a lot you saved me been looking for this answer for hours now

            – MadzQuestioning
            Aug 1 at 13:11













            0














            please try with below code :



            var config = 
            map:
            '*':
            generateMenu:'TCM_HeaderMenu::js/generateMenu'


            ;


            i hope its work for you






            share|improve this answer





























              0














              please try with below code :



              var config = 
              map:
              '*':
              generateMenu:'TCM_HeaderMenu::js/generateMenu'


              ;


              i hope its work for you






              share|improve this answer



























                0












                0








                0







                please try with below code :



                var config = 
                map:
                '*':
                generateMenu:'TCM_HeaderMenu::js/generateMenu'


                ;


                i hope its work for you






                share|improve this answer













                please try with below code :



                var config = 
                map:
                '*':
                generateMenu:'TCM_HeaderMenu::js/generateMenu'


                ;


                i hope its work for you







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 1 at 12:50









                Anas MansuriAnas Mansuri

                1,3642 silver badges16 bronze badges




                1,3642 silver badges16 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f284085%2fhow-to-add-custom-js-in-admin-magento-2%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?