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.

0
votes
1answer
205 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
36 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
38 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
12 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 ...
2
votes
0answers
94 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
26 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
14 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 ...
1
vote
1answer
154 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
39 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
167 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
51 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
15 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
101 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
105 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
180 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
1k 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
18 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
24 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
15 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
258 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
131 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
22 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
14 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
30 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
237 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
18 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
63 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
18 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
200 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
231 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
62 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
47 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
47 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
50 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
268 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
255 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/...
0
votes
1answer
83 views

Magento 2 Admin panel - Cart Price Rule view hangs (spinning wheel), JS Error

How do I resolve this issue? The Marketing -> Cart Price Rules keeps spinning and not loading. Following is the error message from chrome /pub/static/version1544579836/adminhtml/Magento/backend/...
0
votes
0answers
21 views

How can I call JS-file on any page? Magento 2.2.6

I have a custom JS file. But when I try to call it - it doesn't work. I use that code on content -> pages -> my_page: <script src="My_site/file.js"></script> It's just an image-slider. ...
0
votes
2answers
135 views

Invalid Return Type in Ajax Call

I made an ajax script to (at the moment) simply return some HTML to a select. My function looks like this: $.ajax({ showLoader: true, data: {val: inputVal}, /*dataType: 'json', (un)...
0
votes
1answer
63 views

I upgraded from 2.1.9 to 2.2.7 but css and javascript is not working

I tried to upgrade using these commands : composer require magento/product-community-edition 2.2.7 --no-update composer update rm -rf var/di var/generation php bin/magento cache:flush php bin/...
0
votes
0answers
12 views

Project results change event in JS

In Javascript or Jquery is there an event that can be watched to see if the product results set has been changed or filtered because sometimes the window does not reload and my plugin login does not ...
1
vote
2answers
219 views

Module JS - Mismatched anonymous define module

I've tried adding my module JS file to Magento2 but for whatever reason it seems to return this error: Error: Mismatched anonymous define() module: function($) My view/frontend file structure: |-...
2
votes
1answer
93 views

jquery plugin error “Uncaught TypeError: $(…).[plugin function] is not a function”

I am using Magento 2.2.6 and I am trying to include a jquery plugin (stickybits, in this case). The jquery plugin file is successfully called in my requirejs-config.js file and I can see that the file ...
0
votes
1answer
247 views

Magento 2 Update cart automatically on carty quantity update gives error “Mismatched anonymous define() module”

I have done everything mentioned in this post, however, it gives me an error in console: require.js:166 Uncaught Error: Mismatched anonymous define() module: function ($, getTotalsAction, ...
0
votes
0answers
20 views

Integrating Magicsearch(autosearch) plugin into Magento 2 but getting Magicsearch JS error in console

I'm integrating "jQuery Magicsearch" plugin into Magento 2,you can get Magicsearch plugin from here:- https://www.jqueryscript.net/form/Dynamic-Autocomplete-Multi-select-Plugin-With-jQuery-...
0
votes
0answers
16 views

Magento 2 | How to inject JS element on Sales order grid page?

I want to add custom dropdown menu above sales order grid as: What should be the way to achieve this ?
0
votes
2answers
21 views

How to add custom js to the order_status.phtml

I want to add custom js to the order_status.phtml file. where to add the js file and link it to the order_status.phtml
0
votes
1answer
285 views

Trying to override magento2 product view breadcrumbs

So i tried to change the breadcrumbs.html JS template for magento 2.3 product view breadcrumbs in <themedir>/Magento_Theme/web/templates/breadcrumbs.html, but ive been stuck on this for half a ...
0
votes
1answer
35 views

Adding JS File To Module

I've been following a few guides online about adding a JS file to a module but it seems to be going awry for a reason I can't figure out. My JS is a simple file: define([ 'jquery', '...