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.

0
votes
1answer
6 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
16 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
6 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
9 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
13 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
15 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
21 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
26 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
34 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
25 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
23 views

How to add custom validation to checkout phone fild

Good day. 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:...
0
votes
0answers
16 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
30 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
39 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
58 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
29 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
14 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
39 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
41 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
11 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
36 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: |-...
0
votes
1answer
28 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
102 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
3 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
10 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
18 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
34 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
32 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', '...
0
votes
0answers
19 views

How can I increase the speed of my Magento website?

I have a system in magento ready and running, but the speed of the web is not very good. Here you can see a sample of how the web works: https://developers.google.com/speed/pagespeed/insights/?url=...
1
vote
0answers
31 views

How to use javascript in ko template in magento 2?

I have a custom module which will overrride vendor\magento\module-checkout\view\frontend\web\template\shipping-address\shipping-method-item.html, here is the code <!-- /** * Copyright © Magento, ...
0
votes
0answers
11 views

The discount code can't be used automatically after a while?

I have set a discount code on the backend of the website for the convenience of customers. But every once in a while, the user can't use the discount code. I also retested, it is true, can not be used,...
0
votes
3answers
34 views

How to add custom js file in Magento 2 in custom theme without use module

I used custom theme in magento 2. I want to add custom js file for navigation in magento 2 but js file not work. I add js link in default_head_block.xml but a js doesn't work. <link src="js/menu....
0
votes
1answer
33 views

Magento 2 - Request from Javascript is returned with Status code 302

I´m sending a POST request with data via XMLHttpRequest. The response that I´m getting do have the status code 302. Javascript function: function createCSV() { let xhttp = new XMLHttpRequest(); ...
0
votes
0answers
34 views

Magento2: custom javascript not called when using with text/x-magento-init

In list.phtml (product listing) I am showing requistition lsit for every product using type="text/x-magento-init" in loop as: <script type="text/x-magento-init"> { "*": { "...
0
votes
1answer
59 views

Advanced js bundling

I try to optimize the bundles of magento with the information from devdocs . I try to do it on Magento 2.2.6 but the main issue is that after generating the bundles I get an error from the customer-...
0
votes
0answers
19 views

Magento 2 - checkout page loading but not stoping

when ever i click next for check out page some time still loading some times shows empty page How i can fix this....
0
votes
2answers
26 views

How to solve Unable to load CSS and JS after setup magento 2

My using Ubuntu 18 and apache2 I downloaded magento2 zip file and extract uploaded to my /var/www/html/ but always shows the above image I already setup htaccess file Already tried comments: ...
1
vote
1answer
83 views

JQuery how to remove tr in table which are display none in CSS [closed]

how to remove tr in a table which is display:none in CSS
0
votes
2answers
108 views

Magento 2.2: Is it possible to use Vue.js in Magento?

If is possible, how can I integrate it in my custom module?
0
votes
0answers
5 views

M2 | If click on eidt button, update button should become visible and edit hides

I have to update a record. I have gone through this but it is in M1. I have my code in custom phtml file and my function that changes value is: $changeEmail = $block->changeGuestCustomerEmail(); ...
1
vote
0answers
27 views

How to add a configurable external JS with additional data- attributes via requirejs?

I was trying to add an external JS, say https://foo.bar/script.js (the url is configurable via config data) via requirejs, and I was successful so far. But then I realized that I would need to provide ...
1
vote
2answers
22 views

How to include custom JS to admin create new product in magento 2

I want to include custom JavaScript to create new product form. I already try with below way Using XML way. app/code/Namespace/Modulename/view/adminhtml/layout/index_index_add.xml <head> ...
0
votes
0answers
25 views

Product admin edit issue in magento 2

I am getting below error in console, when i try to edit product in admin Uncaught TypeError: data.some is not a function Referred below link and used that didn't solve my issue. Uncaught TypeError:...
0
votes
0answers
19 views

How to render HTML in x-magento-template?

I have used this blog https://webkul.com/blog/how-to-write-javascript-template-in-magento2/ to use x-magento-template. In this I can render data using such code: <%- data.name %> But it shows ...
1
vote
1answer
39 views

Buy On Amazon button

I want to add "Buy on Amazon" button on my product page. I was successful in adding it with this code: <a href="<?php echo $this->getProduct()->getamazonurl(); ?>"><img src="/...
1
vote
2answers
90 views

how to trigger click event in M2

In my header section I have user name and if user have access to different location then he has button saying click me. I want to send ajax call on this button. But JS is not working. Can anybody help ...
0
votes
1answer
19 views

The number of “Requests” is very large

I tested my website performance with Gtmetrix. I found that my website performance seems to be good, but the number of “Requests” is very large. I want to know if the impact of this problem is big? If ...
1
vote
2answers
108 views

Passing magento username and email variables into js script (Magento ver. 2.1.8)

<!-- Head --> <script src="https://wchat.freshchat.com/js/widget.js"></script> <!-- Head --> <script> window.fcWidget.init({ token: "WEB_CHAT_TOKEN", host: "...