Magento 2: Global variable doesn't work with RequireJSWhy I can't access global variable in my observer?Magento 2: can't use materialize.js on my custom modulerequirejs load js but not work - magento 2jQuery event listeners working most of the time but not sometimes?Add js to module via requirejs doesn't work?Magento 2.2.2 - RequireJS domReady! not working with Slick Product SliderMagento 2 - Set global variableHow can I set a global variable in Magento 2?Use of non-amd jquery plugins with requirejs without modifying them?I just implemented Bootstrap 4 in my magento 2.2.5 website. Require.js 166 Error

Why doesn't Anakin's lightsaber explode when it's chopped in half on Geonosis?

Are lithium batteries allowed in the International Space Station?

How would someone destroy a black hole that’s at the centre of a planet?

Why are Japanese translated subtitles non-conversational?

Why limit to revolvers?

How to use "regular expression" to separate specific strings in Oracle

What is the German equivalent of 干物女 (dried fish woman)?

How did John Lennon tune his guitar

Do native speakers use ZVE or CPU?

Deep Learning based time series forecasting

Extract an attribute value from XML

Can a continent naturally split into two distant parts within a week?

Is this more than a packing puzzle?

Why do candidates not quit if they no longer have a realistic chance to win in the 2020 US presidents election

Can I activate an iPhone without an Apple ID?

Behavior of the zero and negative/sign flags on classic instruction sets

What caused Windows ME's terrible reputation?

Hot object in a vacuum

Why hasn't the U.S. government paid war reparations to any country it attacked?

Replacing URI when using dynamic hosts in Nginx reverse proxy

Does optical correction give a more aesthetic look to the SBI logo?

Could the crash sites of the Apollo 11 and 16 LMs be seen by the LRO?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

Meaning of slash chord without anything left of the slash



Magento 2: Global variable doesn't work with RequireJS


Why I can't access global variable in my observer?Magento 2: can't use materialize.js on my custom modulerequirejs load js but not work - magento 2jQuery event listeners working most of the time but not sometimes?Add js to module via requirejs doesn't work?Magento 2.2.2 - RequireJS domReady! not working with Slick Product SliderMagento 2 - Set global variableHow can I set a global variable in Magento 2?Use of non-amd jquery plugins with requirejs without modifying them?I just implemented Bootstrap 4 in my magento 2.2.5 website. Require.js 166 Error






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








0















I'd create a HTML document with a script tag and add this URL



<script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script>


so, call the global variable pagarme in console browser.



I got this response:



client: …, postback: …, company: …, validate: ƒ, search: ƒ, …


But in Magento 2, I always receive error messages.



Below some files with my configuration:



requirejs-config.js



var config = 
map:
'*':
pagarmeJs: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js'

,
shim:
"pagarmeJs":
exports: "pagarme"


;


jsFileWithTheCallingCode.js - first try



define(
['pagarmeJs'],function (pagarme) ...)


jsFileWithTheCallingCode.js - second try



define(
['pagarmeJs'],function () ...)


As mentioned above, if I try to insert the pagarme variable on the console or use inside the require function I always get error messages.



Can anyone help me?










share|improve this question






























    0















    I'd create a HTML document with a script tag and add this URL



    <script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script>


    so, call the global variable pagarme in console browser.



    I got this response:



    client: …, postback: …, company: …, validate: ƒ, search: ƒ, …


    But in Magento 2, I always receive error messages.



    Below some files with my configuration:



    requirejs-config.js



    var config = 
    map:
    '*':
    pagarmeJs: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js'

    ,
    shim:
    "pagarmeJs":
    exports: "pagarme"


    ;


    jsFileWithTheCallingCode.js - first try



    define(
    ['pagarmeJs'],function (pagarme) ...)


    jsFileWithTheCallingCode.js - second try



    define(
    ['pagarmeJs'],function () ...)


    As mentioned above, if I try to insert the pagarme variable on the console or use inside the require function I always get error messages.



    Can anyone help me?










    share|improve this question


























      0












      0








      0








      I'd create a HTML document with a script tag and add this URL



      <script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script>


      so, call the global variable pagarme in console browser.



      I got this response:



      client: …, postback: …, company: …, validate: ƒ, search: ƒ, …


      But in Magento 2, I always receive error messages.



      Below some files with my configuration:



      requirejs-config.js



      var config = 
      map:
      '*':
      pagarmeJs: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js'

      ,
      shim:
      "pagarmeJs":
      exports: "pagarme"


      ;


      jsFileWithTheCallingCode.js - first try



      define(
      ['pagarmeJs'],function (pagarme) ...)


      jsFileWithTheCallingCode.js - second try



      define(
      ['pagarmeJs'],function () ...)


      As mentioned above, if I try to insert the pagarme variable on the console or use inside the require function I always get error messages.



      Can anyone help me?










      share|improve this question
















      I'd create a HTML document with a script tag and add this URL



      <script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script>


      so, call the global variable pagarme in console browser.



      I got this response:



      client: …, postback: …, company: …, validate: ƒ, search: ƒ, …


      But in Magento 2, I always receive error messages.



      Below some files with my configuration:



      requirejs-config.js



      var config = 
      map:
      '*':
      pagarmeJs: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js'

      ,
      shim:
      "pagarmeJs":
      exports: "pagarme"


      ;


      jsFileWithTheCallingCode.js - first try



      define(
      ['pagarmeJs'],function (pagarme) ...)


      jsFileWithTheCallingCode.js - second try



      define(
      ['pagarmeJs'],function () ...)


      As mentioned above, if I try to insert the pagarme variable on the console or use inside the require function I always get error messages.



      Can anyone help me?







      magento2 javascript requirejs global-variable






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 24 '17 at 1:20









      Rafael Corrêa Gomes

      5,0102 gold badges36 silver badges70 bronze badges




      5,0102 gold badges36 silver badges70 bronze badges










      asked Aug 23 '17 at 23:56









      Fernando FauthFernando Fauth

      517 bronze badges




      517 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Got it!



          Simply I use the code bellow in requirejs-config.js



          var config = 
          paths:
          pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

          ;


          And the global variable works!






          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%2f190360%2fmagento-2-global-variable-doesnt-work-with-requirejs%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Got it!



            Simply I use the code bellow in requirejs-config.js



            var config = 
            paths:
            pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

            ;


            And the global variable works!






            share|improve this answer



























              0














              Got it!



              Simply I use the code bellow in requirejs-config.js



              var config = 
              paths:
              pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

              ;


              And the global variable works!






              share|improve this answer

























                0












                0








                0







                Got it!



                Simply I use the code bellow in requirejs-config.js



                var config = 
                paths:
                pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

                ;


                And the global variable works!






                share|improve this answer













                Got it!



                Simply I use the code bellow in requirejs-config.js



                var config = 
                paths:
                pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

                ;


                And the global variable works!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 24 '17 at 3:16









                Fernando FauthFernando Fauth

                517 bronze badges




                517 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%2f190360%2fmagento-2-global-variable-doesnt-work-with-requirejs%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

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림