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
0answers
10 views

Add checkout message based on Customer Group

I'm looking for a way to add a message on checkout page, based on customer group, by code. I would also like to add an extra step on checkout page for another customer group, I was able to add the ...
0
votes
0answers
6 views

Get custom price via price-box widget

I have a single price on the page so i create a method on the priceBox to collect it via an API. The problem i am having is that from my other JS module i can not access this widget or method. Every ...
0
votes
0answers
20 views

Is it possible to load jquery and other js files into magento 2 footer?

Guys I would like to know if it is possible to load js files in magento 2 footer. For example using the tag . And how would I do that?
1
vote
2answers
27 views

How to specify which page js module is included on

I am following this tutorial https://devdocs.magento.com/videos/fundamentals/add-a-javascript-module/ At the end of the tutorial it says Now we’ll go to any product view page, and we should see the “...
0
votes
0answers
17 views

How to call javascript function in magento 2

<div class="block social-login-authentication-channel account-social-login"> <div class="block-content"> <div class="actions-...
0
votes
0answers
14 views

M2: How to validate checkout if certain region is selected?

I need to know how to validate if certain region is selected and prevent placing orders. The thing is that the carrier told us that certain regions are out of their services so if the customer select ...
0
votes
0answers
15 views

Php information on custom module for checkout page

I have created a working custom module that shows a message on checkout page following this solution https://stackoverflow.com/questions/56974955/need-to-write-a-custom-message-on-checkout-page-in-...
0
votes
1answer
18 views

Magento 2 how to use phtml jquery events on knockouts js component template?

I'm struggling trying to approach the following objective: Use jquery events on a knockout js component template. On phtml file I have my knockout js component like this: <div class="container&...
0
votes
0answers
26 views

Magento 2 how to get session value on Javascript Knockout Js?

I'm trying to get a session variable that is created when a customer is redirected to a controller. I'm using \Magento\Framework\Session\SessionManagerInterface $coreSession So I can use it at any ...
0
votes
1answer
26 views

Magento 2 Frontend Toggle Button - Show Hide Content - Options

How can I achieve on Magento 2 Frontend show a toggle button which will show/hide a custom option text area for user to fill in?
1
vote
2answers
44 views

How to add custom script on the header in magento2?

I want to include the js file on the header of the page. But I have selected the 'Move JS code to the bottom of the page' configuration from the admin panel. I want to include one specific script load ...
0
votes
0answers
19 views

Magento 2 Uncaught ReferenceError: jsSHA is not defined

I am getting this error message when I try to use JQuery 1.11.3: Uncaught ReferenceError: jsSHA is not defined. I actually try to download the JQuery js file to call it locally but I gets the same ...
0
votes
1answer
28 views

How can I build the URL from JS file with key - url.builder not working -

I have added a Ajax function to get data, but I need to add secure key to my link. define([ 'jquery', 'underscore', 'uiRegistry', 'Magento_Ui/js/form/element/select', 'Magento_Ui/...
2
votes
3answers
105 views

Magento 2 - Override Mixin with another Mixin

The module Amasty_HidePrice overrides mage/validation by using a mixin. But this mixin has a bug and I need to fix it by overriding the mixin with my own mixin. This is the original mixin (shortened ...
0
votes
0answers
20 views

how to return external js function?

I am integrating custom payment. The payment provider gives a script from their side. need to call a function from their script with the generated token. By calling that function, it will redirect to ...
0
votes
0answers
8 views

Prevent scroll to top after adding to compare , remains on same position

On my category page there is a compare button , when clicked the page refresh and scroll to top, I need to stay on the same position , any idea? thanks
0
votes
0answers
20 views

Javascript show array of value depending on if statment

I need to show an array of values based on current date, for example show only 10am to 13am if we are on current date, if not show all...this is what i have done so far but i cant get it working again ...
0
votes
1answer
5 views

Magento 2: I Want To Make Custom Products Tab On Home Page

I trying to make custom dynamic tab on home page but when do that I get an error Uncaught ReferenceError: tab is not defined at HTMLButtonElement.onclick ((index):1200) Here is my code I don't know ...
0
votes
1answer
14 views

Magento 2 callback dimensionsChanged accordion does not work

I built an accordion from the Magento 2 documentation. CODE JS: $(".init-accordion").accordion({ "active": [1, 2], "collapsible": true, "openedState"...
0
votes
1answer
17 views

Magento 2 - Fix “Please enter a value greater than or equal to NaN.” for input type date

I need to add a date input field to my contact site, so that users can select a date when we can call them back. I filled the attribute min with the date of today, to prohibit the user from selecting ...
0
votes
1answer
17 views

Add custom javascript after js components load

I'm still a novice when it comes to Magento 2 frontend with jsLayout, requireJS, etc. I have a custom module where, in javascript, I am trying to attach an onchange listener to the email textbox. I ...
0
votes
0answers
21 views

JS error “Cannot read property 'timestamp'” at checkout after upgrade from 2.3.3 to 2.4.2-p1

I upgraded Magento 2.3.3 to 2.4.2-p1 and at the checkout it presents this error and just keeps loading the checkout. Uncaught TypeError: Cannot read property 'timestamp' of undefined at UiClass....
0
votes
1answer
29 views

How to pass current value of Ui form field in js file

I want to pass the value of checkbox in custom js file, I am using UI component to create a chechbox. So I have to pass this value to js file and then use that value in Model. I am not able to pass ...
0
votes
1answer
26 views

How to override js files in Child theme? Magento 2.4

I've been overriding a few files in our child theme which seems to work perfectly, however, I don't seem to be able to override JS files. In this case, I'm trying to increase the yearRange in the ...
0
votes
0answers
15 views

How to modify datepicker input template and js file?

I want to change date input data bind attributes and I don't know exactly which file I should overwrite. I changed these files but output is still the same. map: { '*': { 'Magento_Ui/...
0
votes
0answers
20 views

Magento 2: Adding a Javascript library

I am trying to add an animation library called Sal, built on pure Javascript (Does not rely on jQuery). Maybe I am missing something, but I followed the instructions on adding via require-config, and ...
0
votes
0answers
13 views

Structure of a vue application in a magento theme context (NOT STOREFRONT)

Unfortunately google really wants to tell me about Vue storefront whenever I search for it with magento but I only want to integrate vue as part of a regular frontend theme.. Primarily to work on a ...
0
votes
1answer
89 views

Magento 2.4.2 - Strange problem with JS path in a multistore environment

I have a really strange problem. We load a JS file in before.body.end in a multistore setup, like this: \app\design\frontend\Vendor\Theme\Magento_Theme\layout\default.xml <referenceContainer ...
0
votes
1answer
30 views

How is js loaded and removed in Magento 2?

Inevitably, I'm trying to improve our Magento 2.3.0 Pagespeed score. Most of the damage is being done by the excess of unneeded/unwanted js files. Is there any simple way to remove js such as calendar....
0
votes
1answer
32 views

Auto close modal widget after 5 seconds

I created a modal widget that appears after adding product to cart, it works perfectly .Now I need to close the modal after 5 seconds.please help!
0
votes
1answer
22 views

$fotorama not loading consistantly

I know this has been asked before, but I haven't been able to find a solution. I'm using the latest version of Magento 2 with the Porto theme. Occasionally things will load ok (especially in Firefox), ...
0
votes
0answers
21 views

Magento 2 how to use many components inside a component knockout js?

I wan't to import components and use them just like in Vue or ReactJs. Where you can export default component And import it by using import Name from './path/to/component'; and finally use it How ...
0
votes
1answer
34 views

Knockout JS Implementation with Phtml ReferenceError: Unable to process binding

After a lot of search in this forum I have decided to write a question by myself. I am trying to integrate my knockout page into a phtml file in way to update the input layout after a file has been ...
0
votes
2answers
28 views

Change qty script

I use a script to change the qty in the product view page and in the shopping cart page but I have a problem. when I decrease the qty instead the latest value to be 0 is -1. How I can stop the ...
0
votes
1answer
25 views

JavaScript Error (Uncaught TypeError: $.initNamespaceStorage is not a function)

We are running a Magento multi site and on ONE site only, I get this error Uncaught TypeError: $.initNamespaceStorage is not a function All sites use the same theme (just some differences between them....
0
votes
0answers
6 views

magento 2 baler build stuck

I integrated baler in Magento 2 EE. I followed below steps. - $ git clone https://github.com/magento/baler.git - $ npm install - $ npm audit fix - $ npm run build But when I run this command it is ...
0
votes
0answers
16 views

Expected to start loader but did not find one in the dom : loader.js:210 in magento 2 product page

i have see issue in my browser console : Expected to start loader but did not find one in the dom : loader.js:210 in product page. if (window.console && !ctx.parents('[data-role="loader&...
0
votes
2answers
32 views

Magento 2.4 : Frontend/Backend Not working

I am using below configuration : Magento 2.4.x PHP 7.4 Composer 2.0 Frontend and Backend is not working. All .htaccess files are there in required folder. But still,I am getting below log in apache ...
0
votes
1answer
13 views

How to initialize javascript when the user scrolls?

I need the javascript to load after the user scrolls. Right now I have a .phtml file that just has this, <div id="razoyo-gtm-user-code" style="display:none;" data-mage-init='{ &...
0
votes
0answers
5 views

Directory not being unloaded after adding it to the exclude portion of view.xml

I added this line to my view.xml file. <exclude> <item type="directory">Lib::knockoutjs</item> <item type="directory">Lib::knockoutjs/kockout</...
1
vote
0answers
7 views

How to add images in js

How to include images in js, My code : if (firstStore.address && firstStore.state && firstStore.zip && firstStore.store_hours_weekdays && firstStore....
0
votes
1answer
21 views

Input Select File should not allows to override the previous one. is it possible?

Drag and Drop file allows you to override the previous one - should this happen or should it say there's already a file in place? when select next new file.Is there any way to validate previous one ...
0
votes
0answers
18 views

Magento2 UI component focusout event not working

I am using ui component for one the form in admin and for one element i am using component js class to trigger some operations on that element, it only gives onUpdate function, is there anything we ...
0
votes
0answers
20 views

How to get dial code from selected country in textbox before telephone filed using knockout js

I want to develop functionality in that i have created one field for country dial code on checkout page and according to changes of country dropdown dial code will be changes automatically in that ...
0
votes
0answers
20 views

Is there a way to delay the Javascript that gets compiled by require-config.js from being loaded in the browser?

For example in requirejs-config.js I have this var config = { map: { "*": { msapp : "Magento_Theme/js/msapp" } } }; Then I notice that it ...
0
votes
2answers
75 views

Magento 2 - Create simple hello world script with uiComponent

I try to create my own Component and reuse it. So I created these files: THEME = app\design\frontend\company\fresh Component File: THEME\web\js\elements\custom\input_number.js define([ "...
0
votes
1answer
23 views

Magento 2 Uncaught TypeError: Constr is not a constructor when returning functions on Knockout Js

i'm trying to get functions from a JS file in a Knockou file, like this: quote.js define(['jquery', 'uiComponent', 'ko','Vendor_GetQuote/js/ajax-request'], function ($, Component, ko, ajaxrequest) { ...
0
votes
1answer
29 views

Magento 2: How to create popup alert in magento 2

I added a button in block which hits custom controller (I am not using any template) This is controller code: <?php namespace Vtn\UnexportedOrder\Controller\Adminhtml\Order; use Magento\Framework\...
0
votes
0answers
23 views

Magento 2 has default slider js?

Magento 2 provide default Slider js rather than use third party slider js ? Because I do want to increase js size of Magento 2 Store. I tried to search,but I could not find any slider js.
0
votes
1answer
57 views

Magento 2: Translate knockout html where “mailto:info@sitename.com” is used

In Magento_Checkout/web/template/minicart/content.html there is a "mailto:info@website.com" used. Now I can translate the last piece by -- ko text: $t('info@website.com') --> <-- /ko --...

1
2 3 4 5
44