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
1 answer
12 views

How to add data to custom validation rule?

I would like to understand how to add additional data to custom validation rule. I noticed in Magento 2 core files something like the following: validator.addRule( 'validate-...
0 votes
1 answer
16 views

Add product information like name, price and url to ("data" Object in) add-to-cart ajax function - Magento2

I am trying to get some more product data in the add-to-cart event (using ajax). So far, I can see the form works like this: $(document).on('ajax:addToCart', function (event, data) { console.log(...
  • 194
1 vote
0 answers
23 views

when submitting the form from the formbuilder the hash(#) value get removed from the url

I'm trying to submit the request through the GET request by sending the fields as the query parameters, example.com/web/connector/#/home?(other query parameters) when the request is submitted the URL ...
0 votes
0 answers
25 views

Get Time difference in magento 2

I want to tell customers to order the product by 3 pm to get same day delivery. This time is for Uk zone. I want to show the time left for 3pm using javascript https://prnt.sc/Whh8GLttv4zA The hours ...
1 vote
0 answers
24 views

Magento Listrak Integration

I am looking for Magento 2.4 and Listrak Email Marketing Integration. I came across one extension on this but the Listrak team mentioned that they won't support this extension anymore. As per the ...
  • 3,076
0 votes
0 answers
16 views

how to use selectize on input field?

I want to apply selectize on input field to convert comma separated string into tags. What I have done so far. jQuery(document).on('input[name="product[bundling]"]').selectize({ ...
0 votes
0 answers
15 views

How to fix the slider arrows in gallery.phtml

the arrows in the product slider sometimes are hidden, and this is for the class binding that's here <div class="absolute top-1/2 left-0 w-full flex items-center justify-between flex-1" ...
  • 13
0 votes
1 answer
22 views

how to create auto youtube subscribe link

i want to create such a link , when any person click on this link then it redirect to our youtube channel and click automatically subscibe button. (please don't suggest this method ?sub_confirmation=...
0 votes
1 answer
36 views

How to add Custom JS in admin side?

I want to add custom JS on product edit page in admin side. After doing some R&D, i found a solution but that didn't work. What I have done so far, app/code/Vendor/Module/view/adminhtml/layout/...
0 votes
1 answer
26 views

Magento 2 - javascript translations not working

I got a shop with 4 different languages en/de/fr/it. Now I installed translation modules which have their files under app/i18n additionally I have a custom theme under with language files under app/...
  • 1
1 vote
1 answer
30 views

getting Js error in google analytics code

We are using google analytics in our website but getting below error in console. Error: Uncaught SyntaxError: Unexpected token ':' Script: <script type="text/x-magento-init"> { &...
0 votes
0 answers
53 views

Magento 2 How to add custom slider on hyva theme

i am trying to build custom slider on hyvatheme i am only able to find one solution but instructions are not clear in this "https://docs.hyva.io/hyva-themes/view-utilities/custom-sliders.html&...
  • 1
0 votes
2 answers
51 views

Switch between accordion behavior on resize not working properly

I am trying to get a different behaviour of the product tabs/accordion on desktop vs. mobile. I use the matchMedia function to do so. So in the desktop part I use: entry: function () { $('....
  • 423
0 votes
1 answer
26 views

Why are various minified JavaScript files missing in backend?

On the backend login page and within the backend itself the following files from https://store.example/static/adminhtml/Magento/backend/en_US/ are not being found (404): jquery.min.js, js/theme.min.js,...
0 votes
1 answer
40 views

How to initialise Magento Requisition over AJAX?

I have tried several ways to initialize Magento RequisitionList after AJAX call. First I tried with data-mage-init Please correct me if there is anything wrong. I have used the underscore JS template ...
0 votes
0 answers
16 views

Magento2.4.4 malware attack index.php and .htaccess auto generate

Hi everyone, Recently our website has been attacked and index.php and .htaccess are automatically created in pub directory. I have made backup of complete website and working fine on my local ...
0 votes
1 answer
23 views

How to stop external JS from being load from specific layout in Magento?

Magento provides a way to include external js or css using following method. <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url"...
0 votes
1 answer
27 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/...
  • 2,842
0 votes
1 answer
29 views

Magento 2 - How to use custom JS

Why can't I call my custom test() method? Attempt 1 app/code/Company/Test/view/frontend/web/js/test.js define([ 'jquery', 'domReady!' ], function($) { function test() { alert(&...
  • 2,842
0 votes
0 answers
34 views

systemctl status systemd-modules-load is showing inactive

[root@server ~]# systemctl status systemd-modules-load ● systemd-modules-load.service - Load Kernel Modules Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: ...
0 votes
1 answer
62 views

Find Javascript Merge Knockout Error In Extensions Uncaught Error: Cannot find closing comment tag to match: ko template:

Magento 2.4.3 Apache Nginx MariaDB Hello Thanks for taking the time to read this. We have a dev site we are trying to enable Swissup Pagespeed Extension however it is getting 1 error - the merge ...
  • 43
0 votes
1 answer
21 views

Create popup after customer logged in

How to show a popup as soon as customer logs in. I created an customer_login event and called an observer, I want to display a phtml file with my popup code. Following doesn't work etc/frontend/...
  • 107
0 votes
1 answer
65 views

How to create a popup after customer logs in

I am new to Magento..I have successfully created a popup using modal widget in customer_account_index.xml, but this popup works only when customer clicks on My account tab. I am looking for complete ...
  • 107
1 vote
1 answer
148 views

Uncaught TypeError: utils.formatPriceLocale is not a function

I am upgrading to 2.4.5-p1 I can't seem to figure out how to resolve this error. price-box.js:153 Uncaught TypeError: utils.formatPriceLocale is not a function at $.<computed>.<computed>.&...
0 votes
1 answer
66 views

How to add intlTelInput in Magento Checkout

International phone plugin : link I added in my requirejsconfig.js var config = { map: { '*': { customDisplayCheckout: 'Amasty_CheckoutCore/js/custom', }, paths:...
1 vote
1 answer
78 views

Magento 2.3.7 Undefined variable: secureRenderer?

Undefined variable: secureRenderer In Magento 2.3.7 File Path :Vendor/Extension/view/frontend/templates/form/register.phtml <?php /** * Copyright © Magento, Inc. All rights reserved. * See ...
0 votes
1 answer
67 views

Magento 2.4 - Prevent widget from loading on mobile

We have an instagram widget on our site. Perfect for desktops - but very negative for the pagespeed score on mobile. So I would like to prevent it from loading on mobile. Not hide it with {display:...
  • 423
0 votes
1 answer
14 views

Magento 2 How to get this data for password strenght

I would like to get these variables, I see in the magento structure that there are these data calls, and I would like to know how to call them from another javascript file and I don't understand what $...
0 votes
0 answers
54 views

How to override .html and .js files in app/design from my custom module in app/code

Is there any way to override .html and js files present in app/design folder from a custom module in app/code ? I was looking to override app/design/frontend/Vendor/ThemeName/Magento_Checkout/web/...
  • 51
0 votes
0 answers
14 views

Verify if password as a valid format in checkout

I would like verify the password format true or false in checkout with jquery, is it possible ? : for those both fields : <input class="input-text mage-error" data-bind=" ...
1 vote
2 answers
108 views

How to check if form shipping address in checkout is valid

When I do in checkout, I got an error : I would like to detect if the person has filled in the registration form in the checkout, this code is added in this file : app/design/frontend/Theme/theme/...
1 vote
1 answer
28 views

How to use mage/validation on password input

hello I have this field in checkout, I would like use 'mage/validation' to verify if the is true or not. I tried, but it doesn't work, maybe I didn't understand how it works : let password = $('[for=&...
0 votes
0 answers
29 views

How to get Current Store DateTime in Javascript magento2

How to get Current Store DateTime in Javascript magento2. Is any library function available?
  • 131
0 votes
1 answer
71 views

Magento 2.4.3 - Refused to execute Script

I just created a staging environment for my live server and I have some issues with my porto theme after that. I can see it in the inspector "Refused to execute script "script path/frontend/...
1 vote
0 answers
31 views

Magento 2.4: How to add an external Javascript to a CMS Page or Static Block

I got an external JavaScript which is working fine outside of Magento. But if I want to insert that script into a CMS page of Magento 2.4.x there is nothing displayed. Tried a lot of different things ...
  • 2,290
2 votes
1 answer
198 views

Magento 2.4.4-p2 Open menu subcategories only on click

I'm trying to make Magento menu open categories only on click and disable hover function. It opens subcategories but once you open a subcategory it doesn't collapse and you can't expand a different ...
1 vote
0 answers
73 views

Magento 2 Owl Carousel showing giant images and no automatic play

I just configured owlCarousel by using a jquery widget and using it with data-mage-init on my template. The problem is that images are giant, no automaticPlay, no arrows nor dots, in despite that I'm ...
1 vote
0 answers
49 views

Disable Payment Method By JS

I have a requirement to disable the payment method based on a custom product attribute in the cart and payments page, whose value is stored in the cookie local. Till Now I have been able to get a ...
0 votes
2 answers
91 views

Magento 2 Datepicker in checkout default is a disabled date

We recently created a system that allows a maximum amount of orders on specific days, and if that max has been reached the date picker greys out the date, this goes all as expected however currently ...
  • 71
0 votes
1 answer
139 views

How to remove disable attribute from a button in form-mini

I'm trying to remove disable from a button in form-mini.phtml but couldn't find a way through jquery/javascript. I know it gets enabled after adding a few characters, but by default, it remains ...
0 votes
2 answers
159 views

Magento 2 - override JS from third party module from own module

I successfully overrode a JS file of a third party module from my own module named Amasty/AdvancedReviewOverrides. First I copied the file from vendor/amasty/advanced-review/view/frontend/web/js/...
  • 2,842
1 vote
0 answers
93 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 ...
  • 13
0 votes
0 answers
70 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
95 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 ...
1 vote
1 answer
188 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
74 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
722 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 ...
  • 41
0 votes
1 answer
109 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
1 answer
48 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 ...
  • 55
0 votes
1 answer
59 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
2 3 4 5
48