Questions tagged [requirejs]
Denotes questions related to require JS. RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments.
527
questions
0
votes
1
answer
52
views
Magento2 | Reduce JS files to optimize site performance
I am trying to figure out how I can exclude some js files that Magento2 loads and makes it so heavy however without compromising the functionality of the site.
On my site with Magento2 I have a lot of ...
2
votes
0
answers
36
views
How to integrate Google Pay library into website?
I'm trying to integrate Google Pay into my Cart page. But, I always get an error, it looks like this:
Uncaught Error: Script error for "https://pay.google.com/gp/p/js/pay.js" https://...
0
votes
1
answer
59
views
How to prevent user sending requests frequently?
I believe it can be done with a PHP controller or JS cookie manipulation.
Help me with logic. For example, I want a user to send a request once every 2 minutes.
Let's pretend I've implemented some ...
0
votes
0
answers
81
views
bootstrap.min.js:7 Uncaught Error: Bootstrap tooltips require Tether
I am using Magento 2.4.5 and I'm working on jquery. I load some minified js files including bootstrap 4 alpha 6 and tether.min.js but facing some errors in loading tether.min.js. Please help if anyone ...
0
votes
0
answers
138
views
Caught TypeError: self.AnyFunction is not a function
I am trying to modify the default Magento 2 Checkout, basically I want to remove the "Payment and Review" step and put them all together.
Everything goes well but I have stuck intro an issue....
2
votes
0
answers
340
views
Magento 2 : Codazon Fastest Theme js not loading propperly
I Have Installed Codazon Fastest Theme on my Manto2 site.i am facing an issue with js loading.
here is my system configuration below.
magento version : 2.4.5
PHP: 8.0
theme: Codazon Fastest Theme
...
0
votes
2
answers
200
views
How & where is magento javascript initialized on "DOM ready"?
The docs for initializing JavaScript state:
On DOM ready, the data-mage-init attribute is parsed to extract component names and configuration to be applied to the element.
Where does this "DOM ...
0
votes
1
answer
293
views
can anyone find out the error in this knockout js code
this is phtml file located in Namespace_ModuleName/view/adminhtml/templates/js_time.phtml
<div>
<h4>Current Time is:</h4><span id="time_show" data-bind="text: ...
0
votes
3
answers
1k
views
Override js widget variable using mixin
I'm trying to override a widget variable using mixin , but I get the following error Uncaught TypeError: target.extend is not a function
the original file is
define([
"underscore",
&...
0
votes
1
answer
51
views
Magento 2 - Two scripts have method with same name, how to call one specific of them
Situation
The method "test" does exist two times. If I call it while both scripts are required, then only the last one is getting called e.g. the one from test2.js
app/code/Company/Test/view/...
3
votes
2
answers
7k
views
Uncaught Error: Mismatched anonymous define() module
I'm trying to use jquery in an adminhtml js file...but it seems not to be working and can't get to understand why...any help would be appreciated !
Layout is like
<head>
<script src="...
0
votes
1
answer
393
views
How can I resolve the JavaScript error after upgrade magenta from M 2.4.3 to 2.4.5 in Magento 2??
Here I upgrade Magento from 2.4.3 to 2.4.5 so getting a javascript error can anyone help me how can I resolve this error?
Can not find out what excatly issue
0
votes
1
answer
257
views
Magento 2 Should I use multiple require js inside a phtml file?
I need to use require js to use jquery in my block.
Do I have to declare for each function require JS at each beginning or there is a way to declare it only once?
here is my code, thanks
my html
<...
1
vote
1
answer
157
views
Magento 2: Use of map in RequireJs-config
Is anyone know the use of this 'custom' & when we need to use that?
var config = {
map: {
**'custom':** {
'@@@': '@@@',
'@@@': 'js/@@@'
...
0
votes
0
answers
139
views
How to change the LESS variables using javascript based on the admin side configurations?
I am Naveen raj, and I am a new Magento 2 so I don't know how to use the color values inside the less which I got from the admin side. I got value from the admin side and am trying to set that value ...
0
votes
1
answer
187
views
How to add a JS library and a JS script that makes use of that library?
I'm trying to use Chroma library in Magento and so far I did the following two things:
Created a app/design/frontend/Vendor/Theme/requirejs-config.js with the following content:
var config = {
deps: ...
0
votes
1
answer
605
views
change jsLayout html template
How can i change the jslayout html template to be phtml so i can call other blocks in it?
first i have requirejs-config.js below code
var config = {
"map": {
"*": {
...
0
votes
1
answer
1k
views
Component sometimes not loading - "Failed to load the "Vendor_ModuleName/js/view/minitest" component in Magento 2
We are launching a Magento 2.4.2 site, and finding that the site will sometimes load all of its Javascript components and dependencies properly, but sometimes fails to load on the custom component. In ...
2
votes
2
answers
2k
views
A lot of js.map file not found after upgrade to Magento 2.4.3
I just upgraded my magento version to 2.4.3-p1, and after i login to the admin site there are a lot of js.map file not found in the console log message:
How can i resolve this issue ?
0
votes
2
answers
45
views
How to use Jquery lib in Magento 2
Platform: Magento2
I want to import and use 3nd Jquery library in my module. Eg: https://www.jqueryscript.net/other/SEO-friendly-jQuery-Infinite-Scroll-Plugin-Clever-Infinite-Scroll.html use to create ...
0
votes
1
answer
371
views
How to avoid JS minification in an external file add via requirejs-config.js?
I have a custom module called Quicklink it has its own JS files and external JS files too, I've added an external JS from a third-party CDN, but when I enable the JS minification in a Magento 2 clean ...
0
votes
0
answers
628
views
console error:Uncaught TypeError: require.config is not a function in magento2
Uncaught TypeError: require.config is not a function
at requirejs-config.js:18
at requirejs-config.js:19
at requirejs-config.js:757
(anonymous) @ requirejs-config.js:18
(anonymous) @ ...
0
votes
3
answers
687
views
Magneto 2 : how to call code in require js
How to write code in require js, I created layout default.xml file and added code like this
<link src="Test::js/custom.js"/>
And I created web/js/custom.js and wrote like this
...
0
votes
1
answer
206
views
Add Fancybox in Magento 2.4.3
First, I added these files to my custom theme:
app/design/frontend/Custom/mytheme/web/js/jquery.fancybox.min.js
app/design/frontend/Custom/mytheme/web/css/jquery.fancybox.css
Then I edited app/...
0
votes
2
answers
655
views
Magento 2 Js files are not loading from pub/static in my custom module
Magento 2 Js files are not loading from pub/static in my custom module
Js file path as: app/code/vendor/name/view/adminhtml/web/js/grid/columns/thumbnail.js
Even above file is available in static/...
0
votes
1
answer
80
views
Detect IE11 browser and show cms block modal with phtml script tag
I have a modal that pops up when the site detects it's on IE11. The modal is in a cms block so that the client can edit it. I have created a reference container with a custom phtml and put the script ...
0
votes
1
answer
118
views
Magento 2.4 Admin Invoice Does Not Render Properly - uncaught reference error: require is not defined
Magento 2.4.2 admin invoice does not render the CSS on certain invoices - the page shows up without any styling. (Some older invoices do still render properly as they should). So it seems that the ...
2
votes
2
answers
166
views
Magento 2 - New Tax rule page showing "require is not defined" error in console
When I try to add new tax rule I am getting "require is not defined" error in console which cause properly loading issue for Tax Rate, Customer Tax Class and Product Tax Class field (see ...
1
vote
0
answers
30
views
Magento 2 - Load data from store instead of hardcoding
I am creating a new tag programmatically and append it to the DOM.
Currently I hardcoded the phone number, because I don't know exactly how I can load it from the store by using javascript.
This is my ...
2
votes
1
answer
2k
views
how to create a mixin js in magento
in my case i want to add a mixing for just a single line but i can't achieve that
the parent js file is ==> web/vendor/magento/module-customer/view/frontend/web/js/model/customer/address.js
/**
* ...
0
votes
2
answers
639
views
add js file to catalog page magento 2
I am using Magento 2.2.1. I want to add a js file to change one special span tag content with CSS class "price" on the catalog page. I was using document.getelementnByClass.. for my js ...
0
votes
2
answers
1k
views
How to load slick carousel , or any other js file into magento 2?
I'm trying to load the slick carousel into my magento theme and it generates a huge error: "Uncaught Error: Mismatched anonymous define() module". I think it must be related to require js, ...
1
vote
1
answer
88
views
How to add JS file reference in a custom JS file
In a custom module view/frontend/web/js folder I have 2 JS files:
jquery.custom.js
registration.js
In the XML layout file of the module, I have:
<head>
<link src="Vendor_Module::js/...
4
votes
0
answers
155
views
How to use Youtube Player API with jQuery in in Magento 2?
I'm using Magento 2.4 and i'm trying to use Youtube player API with jQuery in Magento 2 .phtml file like this first:
<script>
require(['jquery'], function($){
var tag = document....
1
vote
2
answers
877
views
Swagger Looks Empty Magento 2.4.2
I had updated the Magento 2.3.5 to Magento 2.4.2 the my Swagger is not working i shows the Empty page. The console shows some error and there is a syntax error in swagger like it is showing but i had ...
0
votes
1
answer
533
views
How to access custom attributes from the current product in JavaScript?
I added the following in view/frontend/layout/catalog_product_view.xml:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:...
6
votes
3
answers
5k
views
Magento 2 - Override Mixin with another Mixin
The module Amasty_HidePrice overrides mage/validation by using a mixin. But this mixin has a bug and I need to fix it by overriding the mixin with my own mixin.
This is the original mixin (shortened ...
0
votes
1
answer
847
views
Magento 2: using knockout components within a component
I am trying to render a new KO component within a existing KO template. I have a PackagePopup component which in the template, renders a PackageFfilter component. I would like to seperate the logic ...
0
votes
1
answer
1k
views
Add custom javascript after js components load
I'm still a novice when it comes to Magento 2 frontend with jsLayout, requireJS, etc. I have a custom module where, in javascript, I am trying to attach an onchange listener to the email textbox. I ...
2
votes
1
answer
740
views
inheritance in knockoutJS components within magento 2's knockout framework
I have been experimenting with a custom module with KnockoutJs on the frontend in M2.
I've created two components: a ProductPackage and a ProductPackagePopop. Functionally, the ProductPackage triggers ...
0
votes
1
answer
1k
views
How to pass current value of Ui form field in js file
I want to pass the value of checkbox in custom js file, I am using UI component to create a chechbox.
So I have to pass this value to js file and then use that value in Model.
I am not able to pass ...
0
votes
0
answers
140
views
Magento 2: Adding a Javascript library
I am trying to add an animation library called Sal, built on pure Javascript (Does not rely on jQuery). Maybe I am missing something, but I followed the instructions on adding via require-config, and ...
0
votes
2
answers
317
views
Magento 2 - Create simple hello world script with uiComponent
I try to create my own Component and reuse it.
So I created these files:
THEME = app\design\frontend\company\fresh
Component File:
THEME\web\js\elements\custom\input_number.js
define([
"...
0
votes
1
answer
279
views
Magento 2 Uncaught TypeError: Constr is not a constructor when returning functions on Knockout Js
i'm trying to get functions from a JS file in a Knockou file, like this:
quote.js
define(['jquery', 'uiComponent', 'ko','Vendor_GetQuote/js/ajax-request'], function ($, Component, ko, ajaxrequest) {
...
0
votes
4
answers
535
views
Magento 2 - How does require know where jquery is defined?
You can use jquery in phtml like this:
require([
'jquery'
],function($) {
$(document).ready(function() {
/* Your logic */
});
});
But how does the require know where to find ...
0
votes
4
answers
651
views
Magento 2 - How to use jQuery3?
I try to include jQuery 3 to my project so I can use it on some CMS sites.
Attempt:
THEME = app\design\frontend\company\fresh\
THEME\web\js\jQuery\jquery-3.6.0.js
Copy pasted the code from here to ...
0
votes
2
answers
846
views
How to add color picker in widgets in magento 2.3
i want to add color picker in widget
https://magento.stackexchange.com/a/190260/73525
This above link is working for system config
same thing i want in widget as field
Any one have idea about this
0
votes
0
answers
1k
views
Javascript mixin issues - base is not a constructor
I ran into an interesting issue while trying to create a mixin for a 3rd party JS script. I created the mixin in the normal way with my requirejs-config.js like this:
let config = {
config: {
...
2
votes
1
answer
839
views
Getting the dreaded inconsistent $fotoramaElement.fotorama is not a function
I see quite a few people have this issue, but I can't find a solution that works. I have app/design/frontend/Smartwave/porto_child/requirejs-config.js and I have it shimed, but I'm getting the same ...
0
votes
1
answer
292
views
Magento: addEventListener on change radio button not working using requirejs
Here everything works fine just one issue is there, it doesn't the value and id of input radio fields, So I think domReady addEventListener is not working here.
Help is really appreciated
TIA
This is ...