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

Magento 2.3.4 JS Uncaught ReferenceError with custom payment method

I could need some help. I've added a custom payment method to our shop following this tutorial: https://webkul.com/blog/create-custom-payment-method-magento2/ So far so good, but after loading the ...
2
votes
3answers
66 views

How can overwrite an event from JS file in custom theme or module without overwriting the whole file?

How can overwrite an event from sidebar.js in my custom theme or custom module without effecting anything else that is located in the file? What is the best approach? I need to make the following ...
0
votes
0answers
19 views

Align left with js

How to write the script that will align the text left if checkmark is set in the form . let section4 = document.getElementsByClassName("rightside")[0]; let task4 = () => {};
0
votes
1answer
61 views

Magento 2 - How to use XML uiComponent instead of text/x-magento-init?

I found an easy hello world example from Max Pronko which uses text/x-magento-init to define a uiComponent. MODULE/view/frontend/templates/script.phtml <div data-bind="scope: 'pronko-component'...
0
votes
1answer
42 views

RequireJS and ES6 Style Javascript Module Plugin (Specifically moment-range for moment js) How To Setup Require Config?

I want to load this plugin "moment-range" for Moment which is in ES6 Format here: https://github.com/rotaready/moment-range/blob/master/lib/moment-range.js They do also have it in this ...
0
votes
1answer
83 views

Magento2: Sometime js load sometime js not load properly

I got the JS error in console. Sometime when page load got the JS error and Sometime when page load it is working. I don't know what's the exact issue. I disabled all 3rd party extension after that ...
0
votes
2answers
141 views

Magento 2 - How to write data to window.checkoutConfig from PHP?

I created a new shippping method, I need to generate data and pass it to the window.checkoutConfig javascript object. Normally you do this by implementing the ConfigProviderInterface from vendor/...
0
votes
0answers
8 views

The slider does not cache the first picture. After uploading, the picture is uploaded again

Found a module on github. https://github.com/braumach/site/tree/7bead239da0d181193f77540dd0c0cda791e88d8/app/code/TemplateMonster/FilmSlider It implements a slider with a constructor in the admin area....
1
vote
2answers
157 views

Magento 2 - How to override Method getShippingMethodTitle in Magento_Checkout/view/frontend/web/js/view/summary/shipping.js

I need to override the method getShippingMethodTitle which is defined in vendor/magento/module-checkout/view/frontend/web/js/view/summary/shipping.js. The Method gets the shipping method title in the ...
0
votes
0answers
26 views

Mini Cart Icon dis-appear in mobile menu

I want help with the menu-cart icon that should be dis-appear in the mobile view in Magento 2.3.5-p1. so can anyone have an idea please share with me. Thanks In Advance.
1
vote
1answer
149 views

Edit/modify Google Analytics code from core module, not working - Magento 2.4.1

I want to edit the default Google Analytics code from the core module Magento_GoogleAnalytics, that is build in Magento 2.4.1. I want to add the line; setTimeout("ga('send','event','Profitable ...
2
votes
1answer
53 views

How to add configurable external JS with data- attributes in Magento 2?

I want to add external JavaScript library in my module. It looks something like below script code <script src="<?php echo $block->escapeUrl($block->getJsLibUrl());?>" data-...
2
votes
1answer
45 views

It is possible to deploy only one file using deploy command?

In production mode when I change the design of some particular block or page then I am only working on one or two files like js and CSS. To apply that one change I need to deploy the whole theme. Can ...
0
votes
0answers
11 views

Magento 2.2.4 - checkout/cart get shipping rates via AJAX

Version 2.2.4 seems to have a buggy form post on checkout/cart to update shipping rates. I have other stores using 2.3.* that work fine. I am trying to run defaultProcessor.getRates() on a JavaScript ...
2
votes
0answers
109 views

Magento 2 How to remove Field required validation, if form Div is Hidden

Magento 2 How to remove --data-mage-init='{"validation":{}}-- when div is hidden, I hide div when select box value is not equal to 0 using Script <div class="row"> <...
0
votes
1answer
487 views

Magento 2 - how to add methods to a javascript file by using mixins?

I am using the extension amasty/single-step-checkout. They are using this mixin... vendor\amasty\module-single-step-checkout\view\frontend\web\js\view\shipping-mixin.js (A) ...to extend this magento ...
0
votes
2answers
225 views

How I can make Magento 2 product-info-main sticky like cart sidebar when scroll to down?

I want to make an upper bar as in https://www.atma.com.ar/molinillo-electrico-atma-mc8141n.html that contains the product info and the "add-to-cart" button, and that appears only when I ...
0
votes
0answers
33 views

How to add show/hide link for fields?

Question from new in Magento. I have configurable product (magento2.4) and I need to add show/hide link or button on product page which hides field 1 (input) and shows field 2 (input) and on next ...
3
votes
1answer
97 views

Magento 2.4 deploy command does not creating minify file when I am in production mode

Magento 2.4.0: The static content deployment command does not create minify file when I am in production mode. Getting error on below file. It's not creating so Magento cannot read it. pub/static/...
1
vote
1answer
328 views

Magento 2 Console Error Uncaught TypeError

I have Update Magento version 2.3.4 to 2.4 and now on the product page these errors are coming. Uncaught TypeError: Cannot set property 'migrateVersion' of undefined Uncaught TypeError: Cannot set ...
0
votes
1answer
47 views

Notice: Array to string conversion in shipping delivery on magento 2

I upgraded from magento 2.2.2 to 2.2.11 since I have an error when selecting a shipping address. I get the error: "Notice: Array to string conversion in mywebsite/vendor/magento/framework/DB/...
3
votes
1answer
43 views

How to add custom js file before body tag in magento 2?

But script moving to inside body tag how to fixes this issue? Anyone can help me for this <referenceContainer name="head.additional"> <block class="Magento\Framework\View\...
1
vote
1answer
601 views

How to call javascript function from Observer file in Magento 2

I have created a custom js file in my custom module. app\code\Vendor\Module\view\frontend\layout\default.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/...
0
votes
0answers
8 views

How can I get the type of the selected associated product in a configurable product in Javascript?

I got a configurable product with these options: Download (Downloadable product type) CD (Simple product type) How can I get the product type of the selected associated product in Javascript?
0
votes
0answers
13 views

Magento2 add cart value change the QTY instead of updating

Currently the default behaviour is if i have item X in the cart with qty 5, if i put 8 in the qty box and add to cart the new qty is 13 - the expected behaviour we need to for the cart to change to 8 ...
0
votes
0answers
65 views

Calling PHP block or Controller from AJAX from just a .JS file in Magento2

In other magento2 modules i have used AJAX to call a block from a PHTML file but for this specific task i am needing to make an ajax call to a controller file from a .js file but i am getting 404 on ...
0
votes
0answers
34 views

How to write magento javascript mixin for widget returned as an object?

I need to write magento javascript mixin for the menu.js part which is returned as the object of two multiple widgets. Actual location of the file is lib\web\mage\menu.js which further extends the ...
1
vote
1answer
125 views

Can't close accordion after update from 2.3.1 to 2.3.5-p1

tl;dr After upgrading from Magento 2.3.1 to Magento 2.3.5-p1 our custom JavaScript, part of our custom theme, stopped working. I'm receiving the following error when trying to close the accordion ...
0
votes
0answers
12 views

Magento 2 - how to use my css and js in the theme and in the components

I'm new with Magento. I'm a rails developer and vue developer with frontend experience, and I have to work on a magento theme (it's a store of a friend of mine) I read a lot of documents and I ...
0
votes
2answers
365 views

Magento 2.4: How can we remove datepicker.js in Magento 2.4

How do I remove datepicker.js?? I have tried in layout "default_head_blocks.xml" ```<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See ...
0
votes
0answers
12 views

checkout shipping page add custom field in magento 2.3.5

Now i added custom field checkout shipping page but issue add custom module custom.js and define layout checkout_index_index.xml but it's not working checkout_index_index.xml <page xmlns:xsi=&...
1
vote
1answer
200 views

Remove JS files from beeing loaded through require-js

I am optimizing the page speed of my Magento 2 frontend. Everything is logically so far... CSS files can be removed through XML, everything should be minified, lazy loaded and so on. BUT: The size of ...
1
vote
1answer
41 views

Need clarification regarding JS merging and JS bundling in magento 2.3.2

I need to understand about JS merging, JS bundling and minify JS for site performance Do we need to enable only one option from JS bundling and JS merging? When i enable Js merging, my listing page ...
0
votes
1answer
74 views

Success/error Messages not closing after 2.3.5 update

Thanks for reading. I've been working on a Magento2 project for the past couple months. Recently we updated from 2.3.0(or 2.3.1, I can't remember) to 2.3.5. Sadly, this caused more bad than good. ...
0
votes
0answers
104 views

Magento2 Uncaught ReferenceError: requirejs is not defined and require.js net::ERR_ABORTED 404 (Not Found)

when the mode is production then it is generating require.min.js when the mode is development it is generating require.js The website is now production mode but it is fetching require.js(but file is ...
0
votes
0answers
16 views

Magento 2 Admin Extension Button Not Showing Javascript

We have Latest Mirasvit Advance Feeds extension installed on our Magento 2.2.2. site PHP 7.1 - all the features of the extension are loading fine apart from the + button in the category mapping ...
0
votes
0answers
14 views

Remove all js magento 2 default

i wanna to create Custom Theme without JS magento 2 default. When I enable the require-js functionality magento keeps loading all the default JS files. can you help me handle my problem? thank you so ...
0
votes
0answers
115 views

Please enter a value between NaN and NaN Magento 2

I added a range price slider to my product checkout. Now adding the product works fine. So basically I have a Select input where it contains a dropdown of the price value but I hidden it and made the ...
0
votes
1answer
985 views

Magento 2 - How to get quote shipping method in knockout js?

In Magento 2 I try to get shipping method in this js file : vendor/magento/module-checkout/view/frontend/web/template/billing-address.html I try this : quote.shippingMethod()['method_code']; And I ...
0
votes
1answer
20 views

How to prevent from always static content deploy content on changing JS and CSS work in Magento 2?

How to prevent from static content deploy after changing in JS or CSS file in Magento 2. After doing some little change changes are not loads in front end if doesn't deploy. How to do that Any help is ...
2
votes
0answers
54 views

Magento 2.3 How to apply coupon code discount on regular price

When I apply a coupon code on the cart, it gives a discount on the final price if a special price is set. But I want to apply a discount on a regular price ( If a special price is set on that product) ...
0
votes
0answers
44 views

Download or save page as HTML on Button click

I want to download or save the page as an HTML when someone clicks on the Download button or link. Please check the below code. <button class='download'>Download</button> <a href='#' ...
0
votes
0answers
18 views

Fixed Layered Navigation

I am building a layered navigation module for my theme based off magento 2 blank. I noticed there is no mobile friendly version of the layered navigation included in this theme. I have hidden the ...
0
votes
1answer
18 views

New js in Magento_Checkout into custom theme

Is it possible to create a new js file here or do I need to create a new component?
1
vote
0answers
21 views

Error 400 while trying to POST to orders

When I try to create an order, I get the error 400, can someone help me? Things that may help you guys help me I'm using NodeJS with Express Data that I'm trying to post { "entity&...
0
votes
1answer
344 views

Magento 2 - How to add custom JS file path into CMS Block

How to get JS file in the blocks, How to declare like: <script type="text/javascript"> src="{{skin url=''}}js/my_custom.js"> </script> My JS path: app/design/...
-1
votes
3answers
80 views

How to get Base URL in magento 2 admin script?

I Have added a script ( JS File ) in Magento 2 admin side in my custom module. It added successfully but how to get Base URL in admin side js file. I have tried this Js file path ( app/code/Tym17/...
0
votes
0answers
31 views

Magento 2.2.5 errors in Safari browser

we have integrated one step checkout. it's working fine in other browsers but in safari it's throwing error, because of that credit card form is not visible on checkout page. above is the error i'm ...
0
votes
1answer
24 views

How to add js right before head tag end

I want to add js EXACTLY right before end of head tag I've try this solution, but it only put the js to middle of the head tag, not right before end of head tag https://magento.stackexchange.com/a/...
0
votes
0answers
85 views

Multiple wishlist mixin for mage.promptEditWithList is broken

I have created a mixin to extend the mage.promptEditWithList widget in /vendor/magento/module-multiple-wishlist/view/frontend/web/js/multiple-wishlist.js, but it breaks the edit wishlist functionality ...

1 2 3
4
5
44