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.

Filter by
Sorted by
Tagged with
0
votes
1answer
13 views

magento 2.3.6 - Error: cannot call methods on priceBox prior to initialization

I try to add configurable options in a custom modal page (quick view). But when I open that modal I have the following error: Error: cannot call methods on priceBox prior to initialization and the ...
0
votes
1answer
15 views

How to hide/show html with ajax in frontend?

How to hind / show HTML content (CSS class) via ajax? I have to show / hide products price via the button. I know that it can be done via display: none property, but what are the steps and how to save ...
0
votes
1answer
14 views

How to print string value one by one using javascript for loop?

This is my string "HelloHowAre" I want to print it like this - Hello How Are Using For loop
0
votes
1answer
24 views

After upgrade Magento 2.3 to 2.4 can not add product to cart

After click button ADD TO CART , it's error Cannot read properties of undefined (reading 'remove') and mini cart is empty too
0
votes
1answer
13 views

Font family select is not applying at the same time, its getting updated when I select next font family

this is my select option in html <div class="control"> <select id="selected_font_id" data-bind="value: getObservable('selected_font'), ...
0
votes
0answers
31 views

Include HTML content from external url in Magento2

I have HTML file which is hosted on other server. http://testsite.com/test/index.html which has the content like this(As a example) <!DOCTYPE HTML> <html> <head> <meta http-equiv=&...
0
votes
0answers
8 views

Common Javascript Errors for Magento 2.3.7 Uncaught SyntaxError

This is an error where some of the code is deprected but can be fixed. It is the #porto 3.23 version for Magento 2.3.7 Hoping someone with some experience can help me in this one. VM10437:14 Uncaught ...
0
votes
0answers
13 views

Which Magento Version is Suitable Based on Size of Business and Performance

I have used the Magento versions 1.7-1.9 in the past, and now I've got back into starting a new e-commerce business again. I like Magento the best because the code layout is really smooth for SEO, and ...
0
votes
0answers
9 views

How to change email validation textInput event to focus-out event in checkout

In the checkout page, there is "Billing Email Address" input field which is validated when keyup event is triggered. This element has this data-bind attribute: data-bind="textInput: ...
0
votes
0answers
11 views

Magento 2 - Load data from store instead of hardcoding

I am creating a new tag programmatically and append it to the DOM. Currently I hardcoded the phone number, because I don't know exactly how I can load it from the store by using javascript. This is my ...
1
vote
2answers
20 views

Magento 2 - Dynamic custom validation error message not working

i'm using Magento 2.4.1 and i add custom validation with a custom error message to detect which character is wrong and add it to the message: define([ 'jquery' ], function ($) { return ...
0
votes
0answers
10 views

How to merge theme JS?

I have merged and minified JS from admin panel-configuration-developer-javascript. But when i inspect the homepage, it still shows me more than 100 files in theme folder /pub/static/version/frontend/...
0
votes
0answers
23 views

How do I pass JavaScript variables (from jsfile) in to PHPfile in magento 2

How i pass the js varible from custom js file in to my custom module php file, because i create dropdown in header and i need to use that value for adding some condtion in php file and custom js file ...
0
votes
0answers
24 views

The code looks wrong but works correctly. Is it possible to optimize it and make it more logical?

I have a knockout component that shows or hides my items by tag. I do not work well with js and knockout is new to me, I would like to improve my filtering logic so that it works correctly and locally....
0
votes
2answers
32 views

add js file to catalog page magento 2

I am using Magento 2.2.1. I want to add a js file to change one special span tag content with CSS class "price" on the catalog page. I was using document.getelementnByClass.. for my js ...
0
votes
0answers
15 views

change direction of span price class in magento 2

I have Magento 2.2.1. in price showing which is residing between two span tags with price class, I want to change the direction of that span. when I inspect see lrm; after span tag and I want to ...
0
votes
0answers
19 views

How to filter array and change data on front end KO

I using knockout to create a list with my custom collection data. <div data-bind="scope: 'myData'"> <!-- ko template: getTemplate() --><!-- /ko --> <script type=&...
0
votes
0answers
17 views

How to create required fields in frontend when we would select billing cycle then start and repeat must be fill by user

If user select the billing cycle then start date and repeat must chosen by user. but when user doesn't select billing cycle then the form will be submitted. require([ 'jquery', 'mage/mage', ], ...
0
votes
0answers
11 views

Javascript modules are loading before requirejs

I've some extensions installed. It uses requirejs to load its javascript files, however, on some pages, these modules are requested before requirejs itself. Has anyone experienced something like this?
0
votes
0answers
11 views

Magento 2 advanced JS bundling payment method

I follow the tutorial https://magento.stackexchange.com/questions/273914/magento-2-advanced-js-bundling Ever page is working however when i go to checkout payment it is giving me an error customer-...
0
votes
0answers
16 views

Change minisearch bar input width on hover

I am trying to change the search bar input width when it expands on hover. <div class="search-wrapper"> <div class="search-content block block-search" id="search-...
0
votes
0answers
48 views

PayPal popup issue: When I click "pay with PayPal" the window pops up for split second and then vanishes

When I click "pay with PayPal" in a new browser for the first time the window pops up for split second and then vanishes. This error shows only on the cart page. It shows this error in the ...
0
votes
1answer
35 views

Magento 2: Remove unused JS jquery/ui-modules/slider.js

On Magento 2.3.5 how to remove jquery/ui-modules/slider.js I am trying to remove it from default_head_blocks.xml <remove src=" jquery/ui-modules/slider.js"/> view.xml <item type=&...
0
votes
0answers
22 views

Uncaught ReferenceError: google is not defined magento 2.3.2 in production mode

I am working with magento2.3.2.I am adding Google Maps to the template file. And it is adding successfully in the development environment but facing issues in the production server. I have attached a ...
3
votes
2answers
105 views

How to add "click" or "change" event on product thumbnail images in frontend?

I am trying a "click" or "change" event on fotorama thumbnail images. While clicking the thumbnail images I need to fire a "click" or "change" event. I have ...
0
votes
2answers
56 views

CSS/JS not loading

I am using Magento 2.4.2, I've moved from a VPS to dedicated, on the VPS everything was working , but after moving css/js are not loading, already corrected permissions and regenerated static files, ...
0
votes
0answers
12 views

Add extension attribute to section in checkoutConfig

Hello how i can add extension attribute to discount segment? By default it get discount_lable as title but i wont discount name too. And how i can get shipping method handling free treshold value?
0
votes
1answer
33 views

How to set restriction on checkout shipping step navigate to next button in Magento 2?

I save quote data in one of my custom table in that table grid manage by admin in that I manage on status if this status was enable for that cart and then next button work other wise next button was ...
0
votes
0answers
12 views

i want to add category section bar below my website to show as Mobil app

how can i add this bar below to my website, i use magento 2.3.6 porto theme
0
votes
1answer
17 views

Magento js file 404 error after some working on project (tinycolor)

I use Magento 2.2.1 . After some working on project and adding modules, all things were right until I go to the category page. It gives me error with subject tinycolor.js 404 file not found on console ...
0
votes
2answers
58 views

Magento 2 knockout js onchange selected value not working

I'm working on checkout page. I cannot get the selected value from the event. My Html <select name="addresslist" id="addresslist" data-bind="event:{ change: regionChange}&...
0
votes
1answer
32 views

Loading Admin Settings into JS

so I'm trying to add some new configurations to my checkout page, and I added 3 new settings to the admin page, but now I would like to load them to my JS file, but I don't know what to do to achieve ...
0
votes
1answer
28 views

Make complete sidebar sticky?

I'm trying to make the complete sidebar sticky. I don't think it's possible with only css because there are two elements with dynamic height: .sidebar.sidebar-main { position: sticky; top: 0; } ....
0
votes
0answers
19 views

Issue in currency wise price convert on checkout order summery using Javascript or JQuery

I have product item price with USD $10 and I want to convert this price to INR and display it on checkout order summary. I got currency symbol using utils js but I can't convert price. How to convert ...
0
votes
1answer
26 views

Magento 2: Uncaught TypeError: Cannot read property 'closest' of undefined

I am getting Uncaught TypeError: Cannot read property 'closest' of undefined Here is my code: var _self = this; var btn = _self.element; var parentBlock = _self.element.closest('.new-...
1
vote
1answer
27 views

How to add JS file reference in a custom JS file

In a custom module view/frontend/web/js folder I have 2 JS files: jquery.custom.js registration.js In the XML layout file of the module, I have: <head> <link src="Vendor_Module::js/...
0
votes
0answers
8 views

Custom Options Accordion only working for alternate options

Good afternoon! I have today wrapped our product custom options inside an accordion to reduce the height of the block for products with multiple categories of options, however the accordion sections ...
2
votes
0answers
20 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....
0
votes
0answers
26 views

Google reCaptcha V.2 implementation on one page checkout payment method flow in Magento 1.9

I have been trying to add google recaptcha on magento checkout page where payment methods are toggled, I'm trying to invoke google re-captcha when a button is clicked but it goes through without ...
1
vote
2answers
50 views

What is javascript minification and bundling of files in Magento?

What is javascript minification and bundling of files in Magento? Should I enable javascript minfication and bundling for my Magento 2 website ?
0
votes
3answers
51 views

I want to delete marker from my html, css. Its showing on store view

I have marker showing in my slider on store view how can I remove it, I can't find this code in html. [
0
votes
1answer
32 views

Magento2.4.2 - How to get merged js and css URL?

I need to get the merged CSS and JS files URL for the current page. I have checked the core file vendor/magento/framework/View/Page/Config/Renderer.php::renderHeadContent() public function ...
0
votes
1answer
30 views

Uncaught TypeError : Cannot read property 'websiteId' of undefined

This error occurs when entering the product as pdp. I'm getting an error that I'm using the websiteId somewhere and I can't get it, but I'm not sure what exactly is causing it. Do you have any ...
0
votes
0answers
27 views

Magento 2 Product Page - If price is $0.00 with customizable options, show custom message

Magento 2 Question We got some direction from some previous posts but we are still missing one more piece to the puzzle to complete the functionality. Reference this file: /vendor/magento/module-...
0
votes
1answer
35 views

Get Product-Sku on removeFromCart

I'm trying to get the product-sku (and name) of a product, whenever a customer adds or removes it from his cart or changes the quantity of that product. I was able to come up with the following for ...
0
votes
1answer
28 views

Js error on shopping cart on magento 2.4.2-p1

I have this issue on a 2.2.11 Magento migrated to 2.4.2-p1 : To reproduce it I just have to : -Place product(s) on shopping cart -Go to shopping cart -Insert location for shipping click "order&...
0
votes
2answers
41 views

how to get the value from deferred javascript function (Magento 2.4)?

I copy the js code from How to check that customer is logged in on frontend in Magento 2.1? I have defined the js code on my javascript, but I do not how to get the return value. How to get the return ...
0
votes
0answers
36 views

JavaScript url being stripped out of html

I have a very odd issue happening that I have been struggling with and can't find answer to. We have a 3rd party module to add GTM to the site and after doing a deploy the GTM is fine. After a ...
0
votes
0answers
30 views

How can use jQuery or javascript in amp pages Magento 2

I have used amp module in Magento 2. I want to add custom jQuery to add a class on button click but jQuery is not working. Even I tried to run jQuery in console but this is not working in console also....
0
votes
1answer
29 views

How to access custom attributes from the current product in JavaScript?

I added the following in view/frontend/layout/catalog_product_view.xml: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...

1
2 3 4 5
45