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.

613 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
21
votes
1answer
9k views

Magento 2: Uncaught TypeError: Cannot read property '*' of undefined in (section-config.js:33)

It's duplicate question but I am facing the same issue while adding the product & removing items from the cart page. I have spent almost a day to resolve but no luck hope someone could help me ...
7
votes
5answers
2k views

Update price in checkout page without refresh Magento 2

I have a controller where I apply some discount on the checkout page. Now, I can see the price change just after I refresh the page. I search for a solution, to refresh the price using a Js file. ...
7
votes
1answer
3k views

Magento 2 Add to cart frontend event listener

I am trying to find good solution to execute custom javascript when product is successfully added to cart. Also this custom javascript need information about product that was added to cart (sku, qty, ...
7
votes
3answers
1k 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 ...
6
votes
1answer
191 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-...
5
votes
0answers
51 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="...
5
votes
1answer
81 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. ...
5
votes
0answers
65 views

How to create a basic progress bar with ajax, when il click add to cart in Magento 2?

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 ...
5
votes
1answer
1k 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 ...
5
votes
1answer
153 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 ...
5
votes
1answer
1k views

All product images missing from admin but show in DB and front end

Using Magento v1.9.2.2 with patches SUPEE-7405 v1, SUPEE-7405 v1.1, SUPEE-8788, SUPEE-9652. Browsers: Safari & Chrome on Mac OSX. I'm having an issue where none of the images in the product admin ...
5
votes
0answers
259 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 ...
4
votes
1answer
69 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' }, ...
4
votes
0answers
126 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-...
4
votes
0answers
797 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 ...
4
votes
2answers
51 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 ...
4
votes
1answer
2k 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: ...
4
votes
1answer
3k 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 ...
4
votes
0answers
647 views

RequireJS Error - require.js:166 Uncaught Error: Mismatched anonymous define() module: function (){return Z}

I'm new to RequireJS and trying to figure out why this is happening. I have a custom file stickyNav.js in <vendor>/<theme>/web/js. I've added a requirejs-config.js file in <vendor>/...
4
votes
0answers
216 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 ...
3
votes
0answers
84 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
3
votes
0answers
102 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.. ...
3
votes
1answer
299 views

Defer JS / CSS Magento 2 via layout files?

After reading a lot of devdocs, I can see there is a case for deferring in CSS and JS in the manual https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-types.html#layout-types-...
3
votes
3answers
106 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 ...
3
votes
0answers
137 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 ...
3
votes
0answers
24 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/...
3
votes
1answer
54 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 ...
3
votes
0answers
194 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 ...
3
votes
0answers
91 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 = {...
3
votes
0answers
367 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 ...
3
votes
0answers
189 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.
3
votes
1answer
666 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 ...
3
votes
0answers
405 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. ...
3
votes
0answers
523 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 ...
3
votes
0answers
112 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){ ...
3
votes
1answer
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')....
3
votes
0answers
973 views

magento 2 knockout js / require js subscribe to another files parameter

What I need to do is subscribe to another file / object via knockout js and require js. For example I have in File1.js: define( [ '/path/to/some/component', 'ko' ], function (Component, ko) ...
3
votes
1answer
1k views

Magento 2 - Stuck Checkout loader and Javascript error

I recently upgraded from Magento 2.0.7 to Magento 2.1.2 After the upgrade, I keep running into this issue with a stuck checkout loader and the following javascript error message when I begin the ...
3
votes
0answers
168 views

What does the “initUnique” Method setup in uiElement Objects?

In Magento 2's uiElement objects, one of the initialization methods is named initUnique initialize: function () { this._super() .initObservable() .initModules() ....
3
votes
0answers
309 views

Magento2 : Override Admin Js file

I am working on Magento 2.1 CE. My current active Theme is the Default LUMA Theme I wish to override the CORE Modules "bundle-input-type.js" located in "vendor\magento\module-bundle\view\adminhtml\...
3
votes
2answers
2k views

Inserting Javascript codes in one CMS page of Magento 2.1

I am trying to add some javascript codes in one CMS page of a Magento 2.1 site. Here are what I did and the issues I am facing now: 1)at the "Layout Update XML" of the page, add the following jquery ...
3
votes
2answers
874 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
3
votes
1answer
1k views

Modifying authentication popup

I'm trying to apply the authentication popup on a custom button in my module. I've implemented it by overriding it in my requirejs-config. var config = { map: { '*': { '...
3
votes
0answers
111 views

what does `compatible product` mean in product-media.js?

Can someone explain me what the following code says in product-media.js : getCompatibleProductImages: function(productFallback, selectedLabels) { //find compatible products var ...
3
votes
1answer
2k 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 ...
3
votes
0answers
852 views

Magento Backend issues (Extjs)

I have some issues in my backend : no product categories some buttons not working no editor In firebug console there are several JS errors. example for the categories page : SyntaxError: missing ) ...
3
votes
1answer
2k views

Magento 1.9.1 swatches don't swap images

I've modified my custom template to be able to use swatches with it. (Applied this solution How to use Magento 1.9.1.0 Configurable Swatches in Default package theme (or a custom theme)?) Everything ...
2
votes
0answers
96 views

Cannot read property '$' of undefined Error while using the instantsearch.js file of Algolia. Magento2

I'm trying to get all the data from Algolia so fro that I need to use instantsearch.js file of Algolia and also need to use algoliaBundle.min.js file but when I tried to copy this file then it gives ...
2
votes
0answers
21 views

UI Components - pass ids selection to listing selection

How do i pass a selection of ids to an insert-listing component to preselect certain rows. I have a dynamic rows component with entries related to the current product I'm editing. When click on a ...
2
votes
0answers
25 views

How to pass variable value from phtml JS to block.php?

I have a phtml (system.phtml) with <script> in it and a variable like console.log(data). <?php $checkcustomer = $block->Customerlogin(); ?> <script src="https://d3js.org/d3.v3.min....