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
7 views

401 unauthorized on sign in after creating customer via REST API

I am having some issues with creating new customers using rest api in magento 2.4 First I sign in with admin and get the token to be used later. Than I register new account using ajax: type: "...
0
votes
0answers
12 views

Magento 2 how to access external JS variables and functions in my html template?

I need to access to an external javascript variables and functions so the template does not throws error. I have my template.html template doing this: <!-- ko template: "Vendor_ManualShipping/...
0
votes
1answer
36 views

Emoji is saving as (???????) in the database Magento 2

I added the Emojo library including JS and CSS files. Then it starts to display on the frontend. When I send the Emoji character via ajax. I am getting Emoji in the param request so while saving the ...
0
votes
0answers
22 views

Magento 2 Cookie not able to clear from JS

I am unable to clear the cookie on my Magento site. I am setting the cookie as below which is done successfully use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Stdlib\...
1
vote
1answer
20 views

Magento JS Widget not able to observe submit event on Reorder widget

I am working on Reorder product widget of Magento located as vendor/magento/module-sales/view/frontend/templates/reorder/sidebar.phtml It contains the list of products which are recently ordered and ...
0
votes
1answer
21 views

Magento 2 REST API on add to cart "quoteId" is required. Enter and try again

When I try to add to card any item via REST API I get this error: "{"message":"\"%fieldName\" is required. Enter and try again.","parameters":{"...
0
votes
1answer
18 views

Best way to call JS widget only on specific page

I have created a Javascript widget which does some function based on product add/remove cart action. I would like to include the JS only on product pages viz: Category and Product detail page.I know a ...
0
votes
0answers
18 views

Magento 2 Is it good idea to use ES6 syntax in custom modules?

Some developers suggest avoiding ES6 syntax in JS files to keep the entire codebase unified with a single JS standard. After examining the vendor folder I saw some modules use es6 For example vendor/...
0
votes
2answers
21 views

Magento 2.4.2 - JS bundling not working

I have enabled the Javascript bundling, however, it doesn't seem to work properly. I can see the bundles are being created in pub/static/vendor/theme/en_GB/js: However, the bundles are not being ...
0
votes
0answers
21 views

Magento 2: issue with external call javascipt

I've created custom .phtml file in app/code/Trustmate/Opinions/templates/trustmatewidget.phtml Here I add a short link to the .js code called code from URL with reviews slider on the bottom page. ...
0
votes
3answers
110 views

How to remove ui-modules JS file from frontend?

I would like to remove js file on frontend side from the [magento_root_direcotry]\lib\web\jquery\ui-modules\sortable.js path I tried to remove the JS file by the below code but no luck I tried to ...
1
vote
1answer
15 views

Js regex for UAE Mobile Number

Validate UAE mobile number using js regex. Mobile No- +971 XXXXXXXXX (+971 and 9 digits after it.)
1
vote
2answers
37 views

Why Magento uiRegistry not list some UI Component?

Field Create Code $data = [ 'arguments' => [ 'data' => [ 'config' => [ 'component' => 'vendor_module/js/form/element/ui-select-...
0
votes
1answer
20 views

Magento2.4: https://search.google.com/test/rich-results tool doesn't validate the breadcrumbs properly

the results of testing the URL https://www.perfectmakeupmirrors.com/aamsco-unico-3-with-double-vertical-bands-of-led-lighting.html with the tool https://search.google.com/test/rich-results don't seem ...
0
votes
1answer
41 views

Jquery on click event

Can anyone give example for both click and on click event in jquery? I tried this example for on click, but the same function is happening for a click event also, <!DOCTYPE html> <html> ...
0
votes
0answers
9 views

How to Resize fotoroma library popup/lightbox when clicking on product image on product view page in Magento 2?

I want to set custom height and width of fotorama fullscreen image popup/lightbox. How to do that....please help.
0
votes
0answers
20 views

Magento 2 authentication popup from a custom module

I want to add input email for guest in a popup and after clicking checkout as Guest, it's redirect to the checkout page
0
votes
1answer
34 views

Adding Dynamic Ui Components on select value change

I have a modal where I put a select ui component. I want than when the value of that select is changed I send an Ajax request to one of my controllers search in database an get a json response wich ...
2
votes
1answer
18 views

Rewrite js method issue with mixins

I would like to rewrite this method: grabEmail from a third-party module: define([ 'jquery', 'uiElement', 'underscore', 'rjsResolver', ], function ($, Element, _, resolver) { 'use ...
0
votes
3answers
20 views

Magento 2: Get product custom attribute value in custom js

Hi is it possible to get product custom attribute value in JS? I am getting the product id in JS but I am not able to get the product custom attribute value. Any help would be appreciated. Thank you
0
votes
0answers
9 views

How do I add javascript code to handle callback events after submission of coupon register?

I am using Magento 2.3.5-p2 I am required to trigger a javascript code as below once a user has successfully registered their coupon dataLayer.push({ 'event': 'trackEvent', 'eventDetails.category': '...
0
votes
0answers
13 views

magento 2.4 js console error "order.toggleCustomPrice is not a function"

on the Magento backend admin can create a new order on behalf of the customer. Admin can also set a custom price for each item by clicking on the "custom price" checkbox right under the ...
1
vote
0answers
27 views

How do WeltPixel Google TagManager extension works

I am using Magento 2.3.5-p2 In it, my team have installed the WeltPixel Google Tag Manager Extension (GTM) this extension is to make the process of GTM Implementation easier the way that the GTM works ...
0
votes
2answers
33 views

Include js file script in php observer file

I am using Magento 2.3.5-p2 I am adding a new module to add an Observer that will trigger some js code during an event that happens below are the file and its content I have added File Name and Path : ...
0
votes
2answers
34 views

magento2 before add to cart open popup how to?

submitForm: function (form) { //this.ajaxSubmit(form); var popup = $('<div class="add-to-cart-modal-popup"/>').html($('.page-title span').text() + '<span> ...
1
vote
2answers
37 views

Magento 2 custom popup not work when click of 'Proceed to Checkout'

I have created the custom Popup and open the popup when click on process to checkout in minicart. login popup not work when click on 'Proceed to Checkout' after the login customer account.It's work ...
0
votes
0answers
19 views

Magento 2 Get Event When User View List Product, Sorting, Filter, Clear Options, Pagination, Add Wish List

I am using Magento 2.3.5-p2 As stated in the title, I want to capture an event by the user when the user does any of the processes below User View List Product User Sort Product User Filter Product ...
0
votes
0answers
31 views

The requested URL was rejected while trying to save the address book using special characters

Steps to Reproduce: Go to the storefront Log in as a customer Go to My Account Now go to Address Book and click on add new address button Fill the address form ( add special characters in mandatory ...
0
votes
0answers
16 views

Merging JS problem in Magento 2.4.3

I am trying to enable the merging of a js files, but Magento does not do it correctly. In the resulting file, I see something like this: ... $('#...
0
votes
0answers
13 views

How to know the method available for Magento_Customer/js/customer-data

I am doing a Google Tag Integration on Magento 2.3.5-p2 which require me to capture an event that happens during add to cart and remove it from the cart to capture this event I put in code as below at ...
0
votes
0answers
22 views

how to add "Add to cart" button in catalog search using JS/AJAX in Magento

I want to add the "add to cart" button in catalog search using js. I am getting productname,image,sku. I need to add to a cart button there when I search for a product in the catalog search. ...
0
votes
2answers
23 views

Magento 2 Js files are not loading from pub/static in my custom module

Magento 2 Js files are not loading from pub/static in my custom module Js file path as: app/code/vendor/name/view/adminhtml/web/js/grid/columns/thumbnail.js Even above file is available in static/...
0
votes
1answer
25 views

Logging in and registration in the pop-up/module on all pages in magento, excluding the login and registration page

I created an overwrite path in app/design/frontend/<name_vendor>/default/Magento_Customer/frontend/web/template/authentication-popup.html Here I understand that I can change the texts. Where can ...
1
vote
1answer
47 views

How to call image in js from pub/media in magento 2.4

i want to call image in js from pub/media, if i'm using this code it will call image from pub/static not pub/media. $("."+keypay).prepend('<img data-bind="attr: { src: require.toUrl('...
0
votes
2answers
33 views

Magento 2 - Unable To pass multiple parameters from phtml to a JavaScript component using x-magento-init

I am unable To pass multiple parameters from phtml to a JavaScript component using x-magento-init. Below is my init script. I am able to send the first param (it's a simple variable). the second param ...
0
votes
0answers
18 views

javascript to external js in magento2

I am having javascript code in my phtml file, but I want to do it from layout and create separate phtml file pass variable from require js. Can anyone tell me how to do this? My phtml file code is ...
0
votes
1answer
19 views

Can a vanilla Magento shop be configured to work without Javascript?

The design philosophy of progressive enhancement (and indirectly RESTfulness as well) suggests that a website should work without Javascript (or CSS). I just tried out a vanilla Luma Magento 2.4.3 ...
0
votes
0answers
25 views

How to write and run Js Unit testing in Magento2.4

I have created custom themes and modules. Now I need to write and run the unit tests for the custom-developed modules. Could anybody help me know how to write a js test and how to run the test for a ...
0
votes
0answers
54 views

Changes on LayoutProcessor to make TEXTAREA field input in full width

I am using Magento 2.3.5-p2 on the checkout page to modify its input I have added the content such as below on this file app/code/SR/ModifiedCheckout/Plugin/Block/LayoutProcessor.php // 1- shipping ...
0
votes
2answers
79 views

Add Custom Javascript to method-renderer File

I have created a custom payment module, and when I click the Place Order button, I need it to run a set of custom javascript functions. To do this, how do I include a custom function from another ...
0
votes
0answers
23 views

How can I use Magento2 GraphQL in pure JavaScript?

I see that Magento GraphQL was used to build Progressive Web App. Can I use GraphQL for my simple web application? For example, I need to get all items of the user wishlist on the user dashboard page. ...
0
votes
0answers
84 views

Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

If there is mime or css or js issue then there is chances that in side pub/static .htaccess could be missing. Refused to apply style "because its MIME type ('text/html') is not a ...
0
votes
1answer
46 views

Customizing set-payment-information-mixin.js with Mixin Error

I am trying to convert the error message displayed in error container to alert box. To do so, I have created a mixin for set-payment-information-extended.js on path Magento_Checkout\js\action\set-...
0
votes
0answers
7 views

i added a blog widget in homepage and i want to find the file that have the widget HTML code

I added a widget in my home page content and I want to find the files and HTML code of this widget where is placed in my Magento 2.3.6 files, because I want to edit on it
0
votes
0answers
17 views

Access initialize function's variable in other function

I have a JS file where I am getting .phtml variable dates like: initialize: function (config) { dates = config.dates; this.test(); } test: function(){ //get variable dates } another: ...
0
votes
0answers
28 views

How to get value from helper into javascript file magento 2

I have added a helper as below <?php namespace MyShop\Customer\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; use Magento\Framework\App\Config\...
0
votes
1answer
39 views

Detect IE11 browser and show cms block modal with phtml script tag

I have a modal that pops up when the site detects it's on IE11. The modal is in a cms block so that the client can edit it. I have created a reference container with a custom phtml and put the script ...
0
votes
1answer
45 views

Magento 2 : How to add Translate Code in JavaScript code in PHTML file?

I am trying to add translate code <?= __('This field is required') ?> in the Magento file using JavaScript but it is not working plz help me. if(response.length == 0) { document....
0
votes
0answers
70 views

How to edit a table built with localstorage

I have built an application that takes user input and adds the values to a table on submit. I wanted to integrate an undo button that removes the most recent item that was added from the table. Here ...
1
vote
6answers
2k views

Magento 2.4.3 - Checkout JS knockout error - renderReCaptcha

We upgrade to Magento 2.4.3 and now face the following JS knockout error in the checkout: TypeError: Unable to process binding "afterRender: function (){return renderReCaptcha() }" Message: ...

1
2 3 4 5
46