Skip to main content

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.

825 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11 votes
3 answers
5k views

Magento 2 : Validate form fields that are loaded with Knockout on blur-event

I have a form that is generated through a .phtml file, and in this form various fields are loaded with KnockOut (using the uiComponent javascript-object). .phtml: <form action="#" class="form ...
Giel Berkers's user avatar
  • 12.3k
8 votes
3 answers
2k views

SSL Installed Checkout and Account Area Still Using HTTP and not HTTPS

I am running magento 2 ver 2.0.7 I have an HTTPS issue. I'm not quite sure why this is happening but in Stores -> Config -> Web. I have my secure base url set to https://mystore.com/ but when I ...
steve's user avatar
  • 81
6 votes
1 answer
1k views

Is it possible to drastically reduce the number of JS files being served from Magento without merging/bundling?

Currently my almost-new Magento 2.3.1-based website with a lightly modified theme is sending 170 JavaScript files to the browser, just to serve the home page. To me, this is not remotely acceptable. ...
WackGet's user avatar
  • 1,198
6 votes
1 answer
3k views

Magento 2.2.1 Checkout page broken and Js fail to load error

I have installed Magento 2.2.1 and set up my custom theme but checkout page looks broken and consoles showing errors: Not sure how to resolve this issue. Need help how can this be resolved. How ...
jack's user avatar
  • 920
6 votes
1 answer
480 views

Overriding Magento 2 core js function

I need to override the 'loadArea' and 'loadAreaResponseHandler' magento core js functions in the file module-sales/view/adminhtml/web/order/create/scripts.js. I tried to use mixin property. Following ...
sreelakshmi's user avatar
6 votes
1 answer
697 views

Magento 2: What is the proper format for a javascript widget's _bind() method?

Using 2.1.3, I've been trying to bind page elements to internal javascript widget methods, and have been unsuccessful - the docs (http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-...
dbcn's user avatar
  • 754
6 votes
1 answer
521 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/...
MD Foysal Afridi's user avatar
5 votes
3 answers
2k views

Magento 2.4.3 - JS mixin file not loading on each page load

I tried to overwrite Magento_Catalog/js/catalog-add-to-cart.js only to extend the submitForm method as follows: app/code/Vendor/Module/view/frontend/requirejs-config.js /** * Copyright © Onectus, Inc....
Kloppo's user avatar
  • 95
5 votes
0 answers
2k views

Magento2: Local-Storage Mage-Storage and Mage-Cache Empty on every Reload

Many features in my web page break as when I investigated, I found out that many local storage keys don't even exist now which used to exist before. list of keys that don't exist: lo_session mage-...
summu's user avatar
  • 847
5 votes
0 answers
331 views

Magento2.3: Display Custom text on Shipping Address

I would like to add custom text whenever shipping country is Sweden, Ive created Magento_Checkout module in my custom theme and added a phtml file <div class="free-shipping-info" data-bind="...
paranoid kid's user avatar
5 votes
0 answers
501 views

Magento2 : How to create a basic progress bar with ajax, when I click on add to cart button?

I try to make a basic progress bar with ajax , when I click button add to cart, but I don't know how catch the xhr on console,to put on alert() or prepend()function I follow a video example in ...
Emmanuel Ortega's user avatar
5 votes
1 answer
3k views

how to extend default javascript

I try to extend standard magento javascript configuration but I just get nothing. I'm following this: http://devdocs.magento.com/guides/v2.1/javascript-dev-guide/javascript/custom_js.html and this: ...
steros's user avatar
  • 1,622
5 votes
0 answers
310 views

Magento : WYSIWYG in custom widget

I have tried adding a WYSIWYG editor to custom widget I have created using the approach outlined at: http://behrendtio.github.io/2013/04/12/using-a-wysiwyg-editor-in-a-magento-widget/ However, when I ...
RckMrkr's user avatar
  • 165
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....
Padawan's user avatar
  • 135
4 votes
1 answer
1k views

Magento 2 Uncaught TypeError Cannot read property 'done' of undefined

Uncaught TypeError: Cannot read property 'done' of undefined at UiClass.continueToPayPal (paypal-express-abstract.js:80) at HTMLButtonElement.<anonymous> (knockout.js:4245) at ...
Vishal Baraiya's user avatar
4 votes
1 answer
622 views

Custom JS is not include undefined error magento 2

requirejs-config.js file path isCodility/Customers/view/frontend/requirejs-config.js` and code is var config = { paths: { 'customhighcharts': 'Codility_Dashboard/js/customhighcharts' }, ...
HaFiz Umer's user avatar
  • 1,660
4 votes
0 answers
872 views

Magento 2.3.1 not loading correct javascript files (tinymce)

I've upgraded from Magento 2.2.6 with Theme Ves Fresh 2. I have tried to clean all caches delete static folder and restart Varnish, but had no luck so far. The errors include: GET https://shop....
nicoj's user avatar
  • 41
4 votes
1 answer
16k views

TypeError: require is not a function

I add JS file in custom module Vendor\Module\view/adminhtml/layout/default.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:...
HaFiz Umer's user avatar
  • 1,660
4 votes
0 answers
653 views

Google Chrome is failing in loading require.js files in time

On Magento 2 (ver 2.2.5), with Google Chrome (ver 72.0) I'm getting a wired error I wasn't getting withe previous Google Chrome version (ver 71). When I visit a product page, I get more then one ...
Luigi T.'s user avatar
  • 332
4 votes
0 answers
614 views

Launch Polyfill.io BEFORE Magento 2 scripts

I need to use the https://polyfill.io/v2/docs/ library for a Magento 2 project, so I called it in : htdocs/app/design/frontend/my_theme/default/Magento_Theme/layout/default_head_blocks.xml With this ...
Balix's user avatar
  • 81
4 votes
2 answers
1k views

Magento 2 Missing JS function

Magento 2 Centos 7 Mariadb 10 When I try to add a product from the admin panel, I get the spinning wheel of death. import-handler.js:44 Uncaught TypeError: component.getPreview is not a function ...
Jesse 's user avatar
  • 51
4 votes
0 answers
2k views

Magento 2 : Disable RequireJS (and all JavaScript)

Is there a way to disable RequireJS completely in Magento 2? I want to build a theme from scratch and I do not want to include any of JavaScript that Magento automatically includes, Including ...
fritzmg's user avatar
  • 747
4 votes
2 answers
2k views

Magento 2 Init script after page load

Is there any option to init (text/x-magento-init) script after page load? Example, I am working on a simple quickview feature and my controller returns my a layout - phtml file - with rendered html ...
Rob's user avatar
  • 419
4 votes
2 answers
70 views

broken minicart - urgent

I have attempted to edit the minicart on our webstore, however this resulted in an error occurring which seems to be quite common but no one seems to have an easy fix. The minicart now outputs a JS ...
user avatar
4 votes
1 answer
2k views

Magento 2 Fotorama click event

Is there a way to fire a fotorama click event from a template file? What I am trying to do is have the functionality where, when the user selects an options from the dropdown from the catalog-product-...
Alex Mac's user avatar
4 votes
1 answer
2k views

Using jquery in phtml got an error: Uncaught ReferenceError: require is not defined

I use jquery in my phtml frontend page like this: <script> require(['jquery', 'jquery/ui'], function($){ var currentUrl = '<?= $itemEditUrl ?>'; $('#link-cusom-campaign')....
Hunter's user avatar
  • 1,484
4 votes
1 answer
6k views

Modify checkout step navigation magento 2

I'm customizing the checkout process in magento 2 by adding a custom step between Shipping and Payment steps and by adding a checkbox in Shipping step. The problem When going to checkout page for ...
A. Martz's user avatar
  • 305
4 votes
2 answers
1k views

Magento2 site is not loading properly

I have Magento2 site. When I load first time in the browser it's not loading. Complete and show javascript error in the console but when I refresh, it shows correct? What is the issue in Magento 2
imtiaz's user avatar
  • 117
4 votes
0 answers
319 views

Magento 2: Admin grid table - add new row on the fly?

I created a custom UI grid table in admin. And I have a form on the same page to add new item to my custom database table(with ajax). After I added new item I need it to immediately appear in this ...
Anna's user avatar
  • 1,655
4 votes
1 answer
3k views

How to track product list impressions/clicks and related sales?

We have products in several different categories in our Magento shop. And with enhanced ecommerce tracking we want track the product list performance. I used this Google dev docs. Eg.: Product is in ...
Jurik's user avatar
  • 213
3 votes
0 answers
150 views

Magento 2 Is it good idea to use ES6 syntax in custom modules?

Some developers suggest avoiding ES6 syntax in JS files to keep the entire codebase unified with a single JS standard. After examining the vendor folder I saw some modules use es6 For example vendor/...
Pavlo Bezuhlij's user avatar
3 votes
2 answers
2k views

Why is the loading of scripts via RequireJS incredibly slow when they are not cached?

First of all, this is not a question about general Magento 2 performance. I'm already aware of how to speed up Magento 2, in general. My question is specifically about RequireJS and the assets served ...
WackGet's user avatar
  • 1,198
3 votes
0 answers
107 views

How to create a swipe megamenu for mobile view?

I have created a custom module for Megamenu. In desktop view it looks good and working fine. In mobile view, I want to implement a functionality but I'm not sure how to do that. The functionality ...
MagentoDev's user avatar
3 votes
0 answers
2k views

Advanced JS Bundling - What to include/exclude

So, I've been doing an advanced js bundling for my website and I've read a lot of information about it. I've decided to use m2 dev tools to help me do it, however, I've some doubts with the result I ...
Tiago Costa's user avatar
3 votes
0 answers
277 views

How to translate " This is a required " in Magento 2

I want translate error message required field like this I used de_DE.csv but the get fields from data it does not translate, please help me! Thanks all
Brian N's user avatar
  • 931
3 votes
0 answers
263 views

Magento 2.3.1 CE Tinymce Error

We have upgraded Magento from 2.2.3 CE to 2.3.1 CE successfully. But we are facing few issues with the Tinymce js from admin end product edit page and cms pages etc.. when using Show/Hide Editor.. ...
Nagaraju Kasa's user avatar
3 votes
0 answers
1k views

JavaScript Bundling Not working in Magento2

I have refered https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/js-bundling.html for javascript bundling: After doing all the step i have check Network in browser and it seems found ...
Rutvee Sojitra's user avatar
3 votes
3 answers
899 views

Uncaught ReferenceError: $ is not defined at pricing.js:122 in magento 2.3.0

Hi am getting an uncought referecne error when adding a custom JS in my theme. On the console I am getting this error- pricing.js:122 Uncaught ReferenceError: $ is not defined at pricing.js:122 My ...
user9386912's user avatar
3 votes
0 answers
86 views

js not loading properly in backend product edit while click on show/hide of description field magento 2.2.4 production mode

This issue specific to production mode of Magento 2.2.4. Js is appending in product edit url like : base_url/admin/catalog/product/edit/id/57473/set/12/key/...
groy's user avatar
  • 351
3 votes
1 answer
407 views

Customize Account setting form in Magento 2

In Magento 2, the previous Account Setting edit form has a different layout, like for changing password user has to select the checkbox and then text boxes for password updates pop up, I am changing ...
summu's user avatar
  • 847
3 votes
0 answers
665 views

Magento 2 Knockout Js Customer Name update issue after changing customer name

I am having strange issue. In header, along with Welcome message i am showing Customer full name. For that i am using knockout.js concept. <?php if($block->customerLoggedIn()): ?> <li ...
jack's user avatar
  • 920
3 votes
0 answers
193 views

Overriding\Extending Magento_Sales js files

i need to add my custom function call at the end of function loadArea() which located at Magento_Sales/order/create/scripts.js. I already do this with overriding by requirejs-config.js var config = {...
Nomirimon's user avatar
3 votes
0 answers
2k views

Magento 2.2.5: How to console.log() in js file

I'm trying to debug a js file in Magento 2. And I don't know how to do that. I've try console.log('something in here') but doesn't work, I've clear cache as well. Here is my problem: I've 3 ...
fudu's user avatar
  • 1,288
3 votes
0 answers
224 views

How to combine JS files in Magento 2.2.4

I am using Magento 2.2.4 and want to combine external JavaScript files but, In the admin section I didn't find the options for it under the Developer section.
Rishabh Rai's user avatar
3 votes
1 answer
2k views

Shipping modules does not update rate on zip code changes in guest-checkout page Magento 2 production mode

Preconditions Magento 2.0.4 install Cart page and checkout page Steps to reproduce: 1. Put any product inside your cart 2. Open cart page or checkout page 3. input zipCode to calculate tax for ...
Ganesh Godshelwar's user avatar
3 votes
0 answers
544 views

Headers already send Magento 2 multistore addon domain

Multiple websites are working on Magento 2.2 with the addon domain method and symlinks. The theme is visible, etc. Only thing is that at the bottom I see the following message. Looking for advice. ...
Emile's user avatar
  • 101
3 votes
1 answer
1k views

Callback function for "contentUpdated" event in JS

In Magento 2 we are executing data-mage-init and x-magento-init in dynamic content (ajax response) using using contentUpdated: <script type=“text/x-magento-init”> { "*": { ...
Anjith K P's user avatar
3 votes
0 answers
895 views

How to call a js function explicitly from phtml file in magento 2

I have the following file Vendor/Catalog/view/templates/product/view/type/options/configurable.phtml Content of that file as follows <?php /** * Copyright © 2013-2017 Magento, Inc. All rights ...
Nausif's user avatar
  • 1,554
3 votes
0 answers
378 views

Check if Magento cart is empty using Javascript?

So I need to check if the cart on my magento site is empty or not. I can do this using php like this: <?php $count = $this->helper('checkout/cart')->getSummaryCount(); if($count==0){ ...
hello123's user avatar
3 votes
0 answers
469 views

Javascript file 404s when loaded via Require JS alias

I've ran into a strange problem where a custom javascript file 404s when loaded via a RequireJS alias but it works fine when loaded directly. This does not work Require JS var config = { map: { ...
Ben Crook's user avatar
  • 15.7k

1
2 3 4 5
17