Questions tagged [javascript]

JavaScript (JS) is a client side script language which allows to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed. By default Magento 1 comes with the prototype.js library and Magento 2 comes with jQuery. Use 'prototype-js' and 'jquery' tags for questions about those libraries.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Limit parameter is not working when I add slick slider on related products

I want to add condition on related product where carousel should contain up to 12 products. For that I changed $limit variable and It's working fine without slider. But I added slider, value defined ...
  • 1
0 votes
0 answers
7 views

Read excel sheet data in javascript file

I need to read the excel sheet data from magento 2.4 javascript file. I have overridden Magento_Sales/web/order/create/scripts.js. I can read csv file data without any issue but can't read excel file ...
0 votes
0 answers
33 views

How we get an element from second tab of ui component on edit magento 2.4

I have an Admin UI form with two tabs. There is a dropdown field on first tab .Based on this dropdown value I want to show or hide an another field which appeared on the second tab. But we could not ...
0 votes
1 answer
31 views

Magento 2.4 Failed to load the knockout component

Good morning, could someone help me with the error "Error loading the component "Custom_Module/js/customer-lines" that occurs to me when loading a JS knockout file, the error appears a ...
0 votes
2 answers
30 views

How to add Fontawesome in Magento2 without CDN

I want to load Fontawesome in my Magento2 without CDN. I have downloaded the font awesome library from this link Fontawesome 6.1.1. And in zip file I got these files as shown in the figure . And in my ...
0 votes
2 answers
70 views

Minicart component not working after 2.4.5 upgrade

After recently upgrading a magento 2 install from 2.3.3 to 2.4.5 I'm having problems with the minicart UI Component not rendering anything. After some investigation, it appears that component is ...
  • 1
0 votes
1 answer
46 views

Custom Validation For Checkout Field

I want to add custome validation for example firstname who user can't use number But i don't know why it doesn't work I have create a module and create a file in view/frontend/web/js/validation.Js ...
  • 17
0 votes
0 answers
18 views

Check minicart successfully added product

I have 1 more javascript file, now I want after adding a product to the cart successfully, I want to write an event. Now I want to know how to check when add to cart is successful to execute the next ...
  • 30
0 votes
1 answer
21 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 <...
0 votes
1 answer
18 views

Accordion clickable on mobile and always open on desktop?

In alpine.js how can I reach this? <?php /** * Hyvä Themes - https://hyva.io * Copyright © Hyvä Themes 2020-present. All rights reserved. * This product is licensed per Magento install * See ...
  • 13
0 votes
2 answers
46 views

What is wrong in my ajax url?

I have written the following code the js $.ajax({ showLoader: true, cache: false, url: url.build('multiplecustomer/account/Logout'), type: "POST", }).done(function (data) { ...
0 votes
1 answer
30 views

what is the correct way to add ajax url?

My controller file is Vendor/MultipleCustomerAccount/Controller/Account/LogoutPost.php what should be the ajax url?
0 votes
0 answers
12 views

Magento 2 Js Files only loading from correct url in developer mode

When the store is in developer mode everything works as it should. All the js files are properly linked in the network tab. It gets the file from: base_url/static/version1662993482/frontend/Smartwave/...
0 votes
0 answers
81 views

My build.js is not adding generated bundles in requirejs-config.js file

I followed closely enough the Magento devdoc on advanced JavaScript bundling for better store performance. I see that pub/static/frontend/Perfectmakeupmirrors/argento-luxury-custom/en_US/bundles has ...
0 votes
0 answers
22 views

Magento 2 - Add attribute to script added with "text/x-magento-init"

Magento adds this google analytics script: vendor/magento/module-google-analytics/view/frontend/web/js/google-analytics.js It is getting initialised / loaded here: vendor/magento/module-google-...
  • 2,571
0 votes
0 answers
15 views

braze SDK JS isssue in magento2

I want to add braze SDK to my Magento 2 site. Braze setup is working properly in normal HTML files but when I add it into phtml file in M2 then it is not working and gives me the below error. Uncaught ...
0 votes
0 answers
23 views

Clicking a button scrolls to the top of the page after revealing the hubspot form

Please see the image below as it helps understand what the issue is. When the complete form cta button is clicked, it scrolls up to the top of the page after revealing the form instead of stopping at ...
0 votes
1 answer
22 views

Magento 2 js Uncaught ReferenceError

Im loading a custom module in my javascript file. When in developer mode everything loads, but when switching to production, the script throws this error: Uncaught ReferenceError: InfoBox is not ...
0 votes
1 answer
17 views

magento 2.4 extending 3rd party module js file without overriding it

I have a 3rd party module installed in app/code/ that has a js file injected to the product page via the frontend/layout/default_head_blocks.xml script tag: <?xml version="1.0"?> <...
  • 157
1 vote
1 answer
22 views

Magento 2 date picker validation

Does anyone know how to restrict past day selection in magento 2 date picker using JS mixing. This is the frontend HTML Block That We Copied from the browser. <input class="input-text _has-...
  • 11
1 vote
1 answer
11 views

Get System Config Values in JS file without use of phtml

I want to get System Config Value in my JS file directly without using phtml template. thanks in advance.
0 votes
1 answer
16 views

Magento 2 mixins stopped working

I want to create a mixin on a third party module (MageWorx OptionFeatures) This is what i have now. app/code/MyCompany/MyModule/view/base/requirejs-config.js var config = { config: { ...
  • 398
1 vote
0 answers
7 views

Magento 2: image issue in jspdf

I am using jspdf library to generate pdf and I am unable to print images on the pdf. here is my code: require(['jquery','jsPDF'], function ($,jsPDF) { var logo = 'https://rugs.a2hosted.com/...
  • 161
1 vote
2 answers
19 views

how to pass js window varibles from templates to template files in magento? I want to get system config values in the web folder

I want to pass js window variables from view/frontend/templates/form.phtml to view /web/template/shipping-information.html and view/web/js/shipping-information.js How can I do it? it is because I want ...
0 votes
1 answer
24 views

How to Create a Dynamic Owl Carousel

Using code below you can create a fully responsive dynamic owl carousel. The same way you can implement this carousel in magento2 as well.
1 vote
2 answers
31 views

Frontend JS get access to attributes?

Is it possible to get Magento attribute values on product page when writing custom java script code? I am working on a frontend script where i need access to the product sku to check some logic i am ...
  • 23
0 votes
1 answer
39 views

How to get window.checkoutConfig value in html file using data-bind

I made my custom delivery method programmatically. It also appears in the Magento 2 admin config section. It is a multi-select field with values of days of the week. In my js file below: define( [ ...
0 votes
0 answers
9 views

Cannot include 3rd party JS due to react-js

I'm trying to include some JS from a third-party website using the following in my .phtml file - <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
0 votes
1 answer
21 views

How to get call modal('closeModal') from authentication.html

Question How do I get access to the underlying modal object from a UiClass object? This Magento Stackexchange answer shows how to call closeModal on a modal window: https://magento.stackexchange.com/...
0 votes
0 answers
60 views

Magento 2 open top categories menu on click instead of hover not working on 2.4.4

I've developed a solution to make the top categories menu open 'on click' not 'hover', and it worked fine on Magento 2.3.4. And this is my working solution. My/Theme/view/frontend/requirejs-config.js ...
  • 173
1 vote
0 answers
22 views

Js functions are not working when added Custom section

When i added a custom section. then other js functions( addtocart functionality and slider) is not working on that specific page/phtml custom.phtml <div class="od-qtysection"data-bind=&...
0 votes
0 answers
12 views

JS: access variable defined in parent method inside mixin method

I'm writing a mixin for vendor/magento/module-checkout/view/frontend/web/js/sidebar.js I need to add extra events to _initContent: function () { var self = this, ...
0 votes
1 answer
26 views

Uncaught SyntaxError: Unable to process binding "ifnot: function(){return customer().fullname }"

Upon successful Magento upgrade to 2.4.4 from 2.4.2, I noticed the following error in browser console as site loaded. I don't see any references to this error message on the net nor in SO. Could you ...
0 votes
0 answers
137 views

Magento 2.4.2: TypeError: Cannot read properties of undefined (reading 'includes')

In the payment page of our Magento store did I notice the following error, and I'm not sure if it can be ignore because it is not in red
0 votes
0 answers
5 views

How to make a Magento2 Custom Variable with javascript using 'windows.location.href'

The assignment is simple: Create a Magento 2 custom variable that can be used to display the current URL in some piece of content (in this case a short description). I'm using custom variables a lot ...
  • 1
0 votes
0 answers
17 views

Magento ver. 2.4.3-p1 - "Add new tax class" button is missing Create a new product tax class

There is no "Add new tax class" button in Magento ver. 2.4.3-p1, see screenshot. And the following error in console: Uncaught ReferenceError: require is not defined Any ideas why the buttons ...
  • 1
0 votes
0 answers
14 views

I'm adding gtm tag in magento 2 in head from admin but it is showing inside body why?

I'm adding gtm tag in magento 2 in head from admin but it is showing inside body why? All script tag are moving in body I have (Move JS to bottom from yes to No) but it is showing in body.
0 votes
1 answer
61 views

Magento2: How to get locale code in javascript

I need to get the locale code of the current store ( something like en_EN ) in javascript but I only know the store id : let storeId = window.checkout.storeId;
0 votes
0 answers
27 views

Magento 2.4.2: How to add a Div next to Amazon Pay button in checkout page

I need to place a logo(A credit card image) about the same size of Amazon Pay button next to it where I made a mark in the image below. When viewing the code in Amazon_Pay\web\template\checkout-button....
0 votes
1 answer
26 views

Magento Javascript events

How does one discover which Javascript events exist in Magento 2? I need to run some Javascript code in an adminhtml form for a custom module. The code should run after the fields are displayed (i.e. ...
  • 1,174
0 votes
2 answers
27 views

Cannot Load External JS File on HTML file

Decided to use echarts.js for a specific page in my site. Tried to download the package file on my server and then I tried to include it using a script tag. However, when I open the page I get a ...
0 votes
1 answer
66 views

Magento 2.4.3 not generating *.min.js files

i am working a magento 2.4.3 the config (dev/js/minify_files) is set to 1. When i try to run the command bin/magento setup:static-content:deploy The script exit with the following error Error happened ...
0 votes
1 answer
29 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
0 answers
34 views

Jquery code doesn't work when deployed but runs fine in the browser console in Magento cart page

We're trying to just display the text in the code below if the page is the cart page so that visitors are aware that they can add a gift message to their order. Code works fine by displaying the text ...
0 votes
0 answers
18 views

How to develop frontend using React js Magento 2.4.4

I am stuck on react js integration and development in Magento 2.4.4 so anyone have idea then please share with me. Thank you.
  • 507
0 votes
0 answers
22 views

$_SESSION that has been unset is saved back in magento with custom GTM (google tag manager) x GTM Weltpixel

I have some issue after add custom tag in GTM and setting configuration in magento by Weltpixel for GTM extension so, i have custom tag for tracking event login, logout, banner click, brand click, etc ...
  • 101
0 votes
1 answer
20 views

how to get the return of an ajax request that I didn't send

there is a request that is being made on the site, but I didn't make this request, but I need to get the result of it. Is there anything I can do?
  • 197
0 votes
0 answers
91 views

Magento2 how to get a fully functional slider?

I've got this issue with the slider of the related section in the product page. I'm in Magento2, using Tailwind.css and Alpine.js I've created an apposite .phtml file to have different blocks for ...
  • 13
0 votes
0 answers
68 views

How to implement the Swiper slider in Magento 2

I am new to Magento 2, so I don't understand how to implement the swiper carousel in Magento 2, instead of the swiper carousel I can understand how to implement the owl carousel, and its working fine ...
-2 votes
1 answer
48 views

How to solve this error ? menuAim is not a function

Error: at HTMLDocument.<anonymous> (mega-menu.js:41:28) at fire (jquery.js:3238:32) at Object.fireWith [as resolveWith] (jquery.js:3368:8) at Function.ready (jquery.js:3588:14) ...

1
2 3 4 5
47