Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
0answers
13 views

Magento 2 remove lazy load header cart with items

We are currently developing a new Magento 2.3 store, but we find out that items in the cart in the header, are loaded quite late. When we load a page on frontend, first the entire page loads and then ...
1
vote
0answers
18 views

How can i disable till 1 week next future dates in Magento js Calendar?

I want to allow customer to choose dates after 1 week from current date. Like as today date is 15 Feb 2019 so customer can select dates from 22 feb 2019. I did change js for calendar by adding below ...
1
vote
0answers
13 views

Magento 2.2 x or 2.3 - to bundle or not to bundle

I've read so many conflicting write up's and blogs about whether to "Enable Javascript Bundling" or not. Some say it's slow and some say it's faster when enabled. From what I understand it takes all ...
1
vote
0answers
24 views

CSS and JS merging options is not working on Magento 1.9.2.4

I am simply trying to enable the option of merging JS and CSS on configuration > system > developer and I have cleared the cache and even tried to delete the VAR folder and still having CSS and JS not ...
4
votes
1answer
83 views
+50

Megamenu issue - Clicking menu opens category page for that menu in mobile in Magento2

I need to resolve issue of responsive megamenu for mobile. The issue is when I click on the subcategory to opens its child sub-categories the link gets clicked and gets redirected because of which ...
1
vote
0answers
18 views

JSON.parse: unexpected keyword at line 1 column 1 of the JSON data

I am getting this error in checkout. Below the Shipping Address form, Shipping Methods is stucked on loading. In console it says: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data ...
2
votes
0answers
21 views

Should i use tinymce or tinyMCE in magento 2.3 and also usage for backward compatible

From magento 2.3 i see core team integrated new version of tinymce. It's a good thing. Maybe future they will add more editor for magento. But i have a confuse a bit when to use wysiwyg through below ...
0
votes
0answers
15 views

Magento 2 Add js from my own theme to every page with Miscellaneous HTML

In Content -> Design -> Configuration -> Footer -> Miscellaneous HTML, I can add javascript files like this just fine, <script type="text/javascript" src="http://example.com/myjavascript.js">&...
0
votes
0answers
24 views

Magento2: how to add/remove a form field using javascript

I have created a custom form in admin in which I need to show buttons such as "Add more" and "Remove". The scenario is exact that which is discussed here: https://stackoverflow.com/questions/...
1
vote
1answer
20 views

Programmatically add image to media gallery in Magento2

I am looking at this article on the Gallery API in Magento2. I am testing the code samples in my browser var api = $('[data-gallery-role="gallery"]').data('gallery'); However, this returns undefined....
0
votes
1answer
12 views

Magento 2.2.7. Best way -according to the Magento guidelines- to apply some custom javascript to specific products

At app/design/frontend/Custom/Theme/Magento_Catalog/templates/product/list.phtml I'm trying to apply a javascript for certain products (not all of them) as follows: <?php foreach ($...
0
votes
1answer
23 views

Show and Hide Product Grid in custom module Magento 2

I have created a drop down field. When I select 1 option from field I want to show the another field and along with that I want to hide product grid. Same as when I select 2nd opinion, I want to show ...
0
votes
0answers
5 views

Magento 2 implement Readmore.js from jedfoster

I want to implement Readmore.js to our Magento 2 store. See: https://github.com/jedfoster/Readmore.js For some reason it does not work, maybe due to conflict jQuery with default Magento 2 code? Is ...
0
votes
1answer
39 views

Magento 2 read more and read less in description product page

I want to add a read more and read less button in the description on the product page. I do not want to cut the entire text and onclick of the read more show another div with the entire content. I ...
0
votes
1answer
23 views

Remove alert.js file from magento 2

I want to remove alert.js file from my DOM. following is the file location "vendor\magento\module-ui\view\base\web\js\modal\alert.js" I tried so many ways in my child theme's default.xml file <...
0
votes
1answer
25 views

Remove annoying calculate button from Magento 2 Bundle Page layout

I have set up a bundle product and its working but can I disable the javascript that forces me to click on calculate every time I use it? I want it to open in "calculate mode". I dont know what Im ...
0
votes
0answers
11 views

Passing data as Javascript variables without caching

I've made some modifications to Magento's swatches via a custom module to display out of stock options on the product page (as non-selectable deactivated swatches, so the user will know that the ...
1
vote
0answers
47 views

Magento2 error after theme upload: Invalid template file

After uploading new theme files (Hebes) to Magento 2.3 installation I receive the following error: 1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file:...
0
votes
0answers
13 views

Magento 1.9.2. - JS and CSS that block the view above the fold

I'm searching the web for a definitive solution to the "problem" that google reports when i test the speed of my site on Google PageSpeed. Magento's JS and CSS block the above-the-fold view and I ...
0
votes
0answers
10 views

I can't disable event FacebookPixel in Checkout page

I have created a module to install facebook pixel on magento. My problem is when I created the disable page view function. It disabled on the url: http://localhost/magento2300/checkout but when I ...
0
votes
1answer
25 views

Magento 2 get store configuration in js

I'm trying to get admin store configuration (core_config_data) in mincart.js file. Is there any method to get this ? like define([ 'storeConfiguration' 'uiComponent', 'Magento_Customer/js/...
0
votes
1answer
13 views

Override javascript with self-minified versions

We tried enabling the built-in minification and javascript merge functions, but some functionality of third-party modules/plugins stopped working. So something is in conflict between how magento is ...
0
votes
2answers
29 views

Magento 1.9 - How to get price format in javascript or jquery?

I am trying to get magento price format in php file using jquery / javascript function but facing problem. What I have tried .... <script> var price = 10; var priceFormat = '<?php echo Mage:...
0
votes
2answers
22 views

Error while calling an API through ajax

I have added a code inside the script tag for an on-change function. But i am m getting error like this Server cannot understand Content-Type HTTP header media type application/x-www-form-...
1
vote
1answer
13 views

How do I utilise Javascript merging?

To be clear, this is not a post about Javascript Bundling. This is about Javascript Merging. So, I'm in Production Mode and I'm starting to look at the optimisation of Javascript Merging. My ...
0
votes
1answer
12 views

Own recently viewed widget (magento 2)

I want to make own recently viewed widget, cause this standard loads items with javascirpt (I want to have items directly). So I made this code, based on other posts: namespace AA\WidgetRecently\...
0
votes
0answers
28 views

Mailchimp popup not working

I am trying to add a mailchimp popup to my magento site. So in the footer.phtml I added this: <script type="text/javascript" src="https://downloads.mailchimp.com/js/signup-forms/popup/unique-...
0
votes
0answers
32 views

Magento 2 - (Shipping Address) Custom city dropdown validation not working in checkout page

I followed this link. I created a custom shipping method and I need the city to be required for my shipping rates to be calculated. My problem is my shipping-rates-validation doesn't get trigger it ...
1
vote
2answers
106 views

Magento 2 How to bind knockout event on ajax html response

I have created custom functionality on item form on cart page like increment/decrement qty, remove product with a custom popup, custom move to wishlist by knockout js. For knockout events, I created ...
0
votes
0answers
7 views

Class not defined in validation.js after upgrade to 1.9.4.0?

I updated from 1.9.3.7 to 1.9.4.0 using the .mage command line tool. Everything works fine in the admin, the frontend however always shows me Class is not defined. The code where this happens is in ...
0
votes
1answer
18 views

Magento 2.1.9 - Cannot seem to overwrite JS comonent template in custom module

Having trouble trying to overwrite a JS component template at checkout. Here is my module structure and code for this specific task: app/code/MY/MODULE/view/frontend/layout/checkout_index_index.xml &...
0
votes
0answers
8 views

Magento 2 user field validation using an API

In a dedicated data table where we stored customer's privilege card number in order to validate them with users that they enter to a field called "privilege card no" On such an occasion I'll have to ...
0
votes
1answer
25 views

Magento 2: Including External JS - Uncaught Error: Mismatched anonymous define() module

Trying to include an external JS file on a specific page. Currently using the following in my layout: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
1answer
34 views

Magento 2 Cart Summary loading after code execution

When I visit the checkout page, the checkout summary loads after my custom.js file. This means when i'm trying to pull values from the summary to perform some logic on these values always return null. ...
1
vote
1answer
21 views

Magento - Should I stop to write JS/CSS directly in the backend in CMS pages?

In Magento you can create CMS pages. It is also possible to add CSS and JS code, directly to the page, which I sometimes do for rather smaller changes and style fixes and such, because then that ...
0
votes
0answers
7 views

JS Error breaks Minicart in developer mode only Invalid template file

I'm working on a project and I'm getting the below browser console error only in developer mode when I add an item to the cart Invalid template file: 'cart/item/price/sidebar.phtml' in module: '...
1
vote
0answers
16 views

Mega menu issue with product zoom

I am using Magento 2.2.6 on the product page, When you view a product, and then you go to Products Menu, once the mega menu is shown up, move mouse to the menu item over the product picture area, then ...
0
votes
1answer
15 views

What is the difference between creating a new Map with or without parentheses?

I'm able to create a new Map without the parentheses like so const withoutParentheses = new Map; or like this const withParentheses = new Map(); Same goes for Set I haven't been able to find any ...
0
votes
3answers
31 views

Failed to load resource: the server responded with a status of 404 (Not Found). How to solve this issue?

I am running Magento 2.3 with NGINX, PHP7.1 and MariaDb. This is a fresh instalation with pre-loaded data. I am getting these follow error: $ tail var/log/system.log [2019-01-09 16:36:24] main.ERROR: ...
0
votes
1answer
17 views

Payment method buttons sometimes work sometimes no

I need a little help, sometimes the buttons of the method payment doesn't work, I can't find what is going on, in the most of the cases they work.
0
votes
1answer
25 views

Override aheadworks onestepcheckout extensions cc.js file

I have been looking a lot on how to override/extend js files, found a way using mixins but I cant figure it out how to do it correctly because it did not work for me. The file I need to override ...
0
votes
0answers
13 views

M2: How to change title in browser after switch card

I'm use this script: https://fabriceleven.com/dev/changing-tab-title-focus-loss/ In content ---> Design --> Configuration --> Footer --> Other code (before section body) I put code: <script type='...
0
votes
2answers
37 views

How to hide messages after certain time

I want to hide success / error messages after 5 seconds once I have added items to the cart. I have extended messages.js with the following code to hide the message after 5 seconds setTimeout(...
1
vote
1answer
52 views

Magento 2 How to set Config Provider for all pages?

I created one module. which have helper function which returns module is enabled or not? Now I want to check if this module is enabled or not in javascript for all pages on the frontend, for that, I ...
0
votes
1answer
32 views

How to override “vendor\magento\module-catalog\view\base\web\js\price-utils.js” in our custom module Magento 2?

I have created the module, now I want to override the vendor\magento\module-catalog\view\base\web\js\price-utils.js file in my custom module to change in one function. I tried with below code: ...
1
vote
1answer
28 views

How to add custom validation to checkout phone field

I have checkout_index_index.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/...
0
votes
0answers
23 views

In Magento 1.9, how to access session id on the client side using javascript?

According to the following 2 answer, PHP session id is stored on the client side and with each request, the session id is sent to the server which is what helps the server in identifying the client. ...
0
votes
1answer
38 views

How to create auto call javascript multiple function in magento 2 in single file

I create two js file for a task. I want to merge two file task in one file in three function. Both two have different config parameter. I am using magento x init. <script type="text/x-magento-init"...
1
vote
2answers
67 views

Magento2 Remove JS from Homepage

In my website homepage there are multiple bundle js <script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle0.min.js">&...
1
vote
4answers
87 views

Admin Url CSS and JS not working

I tried every possible solution on this forum and nothing works: php bin/magento setup:upgrade php bin/magento cache:clean php bin/magento setup:static-content:deploy core_config_data dev/static/...