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;
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
add a comment |
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
add a comment |
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
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
magento2 javascript requirejs global-variable
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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!
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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!
add a comment |
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!
add a comment |
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!
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!
answered Aug 24 '17 at 3:16
Fernando FauthFernando Fauth
517 bronze badges
517 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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