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
1
vote
0answers
22 views

Executing Jasmine tests for frontend theme's

I can't get some of the Jasmine tests for the frontend (blank and luma themes) to work. I have generated the static files as described in the documentation. $ bin/magento setup:static-content:deploy ...
1
vote
0answers
25 views

Show all error messages in one place in one page checkout

I want to show validation messages in one place. for example. <div class="checkout-error-message"> * Please fill address field * Please fill email field * Please check agreement and term </...
1
vote
0answers
17 views

Fire JS script in observer

How can i fire this JS with an observer every time a user is adding, updating or deleting a product from the cart ? <script type="text/javascript"> _paq.push(['addEcommerceItem', "{{...
1
vote
0answers
10 views

How to list all JS outputed via module?

I want to have all the JS outputted as it's in the HTML, so if the bundle, minify and CDN are enabled or not I would like to get the URL listed via my module. How could I do that?
1
vote
1answer
33 views

How to remove tooltip from email field on checkout

Tell me how to remove tooltip from the checkout email field. I tried this way app/code/Dv/Tooltip/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\...
3
votes
1answer
109 views

Magento 2 after running upgrade command images, css & js deleted

Whenever I run upgrade command in Magento 2, some of my CSS and JS and Images files deleted automatically, sometimes deleted from third party modules, and sometimes deleted from magento vendor folder. ...
0
votes
0answers
14 views

Magento2: How to use checkbox in model popup in js?

I have created a model popup, that will appear when user click on add to cart. Now I want to add check box to accept user acceptance by click on checkbox. Can someone please help to to do this.
0
votes
0answers
32 views

Separation of bundle configurations and display of different content

Tell me how to solve the problem. I have a form in which data about bundle product configurations comes. The code that downloads this in the .phtml file is: <?php /** @var $block Magento\...
0
votes
2answers
46 views

get product id from item id in magento 2

I am trying to retrive product id from item id. i created first js function in sidebar.js: define([ 'jquery', 'Magento_Customer/js/model/authentication-popup', 'Magento_Customer/js/customer-data', '...
3
votes
0answers
29 views

How to create a swipe megamenu for mobile view?

I have created a custom module for Megamenu. In desktop view it looks good and working fine. In mobile view, I want to implement a functionality but I'm not sure how to do that. The functionality ...
2
votes
0answers
14 views

How to get the shipping rates via AJAX?

When I update the product qty in the cart page I want to have the shipping rates estimated again via AJAX, how could I call this JS method in order to do that?
1
vote
0answers
10 views

How to integrate ReactJS with Magento 2 frontend

For example I have to build a contact form in header. I want to create a module and then call that module in header
1
vote
0answers
30 views

Advanced JS Bundling - What to include/exclude

So, I've been doing an advanced js bundling for my website and I've read a lot of information about it. I've decided to use m2 dev tools to help me do it, however, I've some doubts with the result I ...
0
votes
0answers
22 views

Magento2 How To Create Class Element Using React JS

I have used below code to work with react js but getting below error. ReferenceError: React is not defined I have add react.js file using default.xml And Also one another file form.js and ...
0
votes
2answers
56 views

Inline JavaScript file in phtml

Is it possible to inline JavaScript file into phtml file? we have phtml file in view/frontend/template/js and js file in view/frontend/web/js <!-- current setup --> <script type="text/x-...
1
vote
1answer
13 views

Magento1.9 : Translate validation messages for different stores

In my having two stores France and German.I want to validation error messages with their particular languages.How can I do it with my Js script? My code <label for="sample" class="required"...
0
votes
0answers
7 views

add extra cost on front end by javascript

I need to add an extra cost to the item based on javascript events on the product page. The cost will appear on invoice order how can I do it? Thanks
0
votes
0answers
19 views

How to make changes to JS files effective without the need to run and re-run setup:static-content:deploy?

The theme and locale specific setup:static-content:deploy task at my server takes about 10 seconds to finish. My question, how to make changes to theme or module JS files effective on page reloads ...
1
vote
1answer
23 views

How to get customerData in js uiComponent asynchronously?

This is the usual way to get customerData on frontend. define([ 'uiComponent', 'Magento_Customer/js/customer-data' ], function (Component, customerData) { 'use strict'; return ...
1
vote
1answer
34 views

Magento 2 - Admin js config

In Magento 2.3 inside of a template for the admin area: Moduel\Vendor\view\adminhtml\templates\template.phtml I'm trying to add a button to open up the MediabrowserUtility with the url. Code ...
0
votes
1answer
32 views

How to Override Magento Add to WishList Widget

I want to Override Magento add-to-wishlist data-action in Magento 2 i Have Created and Override Core addtowishlist Widget in my requirejs-config.js var config = { "map": { "*": { ...
0
votes
0answers
7 views

How to create a local callback to a JS via CDN using RequiredJS?

I've some JS files included in my themes and modules, but sometimes these files are not loaded, becaused of adblock or CDN server down. I checked the RequireJS documentation and I saw that it's ...
0
votes
0answers
20 views

Magento2.3: How to make a sticky header?

I have tried to make a sticky header but no success. I have followed many posts regarding this but none of them is working for my case. I have followed below link. Fixed Headers in Magento Any help ...
3
votes
2answers
45 views

What is the difference of map vs path?

What is the difference between map vs path when building a theme / module? Which are the restrictions? var config = { map: { '*': { 'jqueryjs': 'India_Newtheme/js/jquery', '...
0
votes
0answers
20 views

Why is it adding a min extension to the JS path getting a 404?

I'm requiring an external JS file via requirejs-config.js but my Magento 2.3.2 is getting with .min included, but there is no this .min, so I'm receiving an error 404, I don't want to move it to my ...
1
vote
1answer
40 views

Get street address in checkout page magento 2?

Hello all I am trying to get selected shipping address from dropdown(without changing the dropdown option like getting selected shipping address when page loads) or default shipping address on ...
1
vote
2answers
31 views

Changes in js file not getting reflected in frontend in magento 2.3

I did some changes in js file of a third party extension. The path shown on frontend is /pub/static/version1574138983/frontend/Smartwave/porto/en_US/Mageplaza_LayeredNavigation/js/view/layer.min....
0
votes
1answer
18 views

Mageplaza navigation layer.js not working

Mageplaza layer navigation js updated from app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/view/layer.js this location but it is not updated. but on console js event is showing on below ...
0
votes
0answers
36 views

Magento 2.2 display brand logo product detail page

Please can someone provide step by step instructions or provide tutorial on how to display brand logo on product detail page above the add to cart button. Thanks
1
vote
2answers
76 views

Magento 2 pass php session variable to minicart & hide proceed to checkout

I would like to pass a PHP session variable flag to mini cart-mixin.js dynamically. I followed the below steps mentioned here using the Config Provider concept I am able to pass variable to only cart ...
1
vote
0answers
27 views

How to hijack a button's click event with my own ajax get function? Magento 2

I am tying to add a new button to an existing admin page. I want to call an ajax get() function on this button click. I created a main.js script file which I see is loading on this page since when I ...
0
votes
0answers
12 views

How magento 2 binding value to switcher checkbox toggle input

1 Not sure why when input disabled the value binded with 2 Answered myself Info: Magento use 2 indicate product status disabled Class Magento\Catalog\Model\Product\Attribute\Source\Status 2 how ...
0
votes
0answers
18 views

Magento2 - How to override require_js.phtml for a specific button click?

I have a custom module built that is loading a require_js.phtml file onto a page. I want to add another button to this page and write a new ajax call to be triggered on this button click. Currently ...
1
vote
1answer
16 views

Translate test inside div in magento 2?

I have this piece of code inside app\design\frontend\Company_name\porto_base_child\Magento_Checkout\web\template\shipping.html <div id="poboxmessage" style="display: none; color: red;">...
0
votes
0answers
10 views

Shipping amount is lost with call function estimateTotals Magento 2

In my module I have my own discount and when I load the pag custom discount doesn't load. I try to call function estimateTotals and after it shipping amount is lost but show my discount. That I do: ...
0
votes
1answer
38 views

Submit checkout form with JS after processing payment on checkout page only

I've integrated some custom payment module. I am getting trouble with form submission with JS after payment response. I need to submit the checkout form on click of place order but with JS and that ...
0
votes
2answers
54 views

How to use url.build in JS?

I am getting Uncaught TypeError: url.build is not a function I need to use ajax in JS to get the controller method on the checkout page on click of place order. This is my JS file require(['...
2
votes
2answers
83 views

Magento 2 Inject UI component(s) via ajax into adminhtml form

I've build a regular adminhtml form via UI component(s) including multiple fieldsets, input and select fields. All working like they should. Now I've created a so called 'Event' select field within ...
0
votes
0answers
18 views

check whether a product contains specific attribute in checkout tabs

I am new in Magento and i am trying to add a special validation in the checkout page of magento2. for that, I created one more tab in checkout page. I need to show that custom tab only when cart ...
0
votes
0answers
12 views

Magento 2 mixin error

I didn't use mixin in my custom theme or anything. But I get the below error. TypeError: mixin is not a function My require-config.js is below. var config = { paths: { 'owl.carousel': '...
0
votes
0answers
25 views

Getting console error how can i solve this?

Getting console error how can i solve this?? random errors coming Failed to load resource: net::ERR_CONNECTION_TIMED_OUT require.js:141 Uncaught Error: Script error for: Magento_Variable/js/...
1
vote
0answers
25 views

Code Pattern to Define and Use Javscript Callbacks / Hooks

We are using a third party module, that updates prices via AJAX on product / category pages. No we have to react on this update, to update some custom pricing logic. Of course we do not want to patch ...
0
votes
2answers
29 views

How can we split js file from phtml file

We currently have a large phtml file that is essentially a plain JavaScript file, eg., <?php // some conditional check. about 10 lines of code > <script> // here is 1000 lines of ...
0
votes
1answer
55 views

Uncaught TypeError: Cannot read property 'innerHTML' of null

We have tried to do a checkout on our website but its not working. When looking into the console, it says the below error Uncaught TypeError: Cannot read property 'innerHTML' of null and its ...
2
votes
0answers
28 views

how to use highcharts.js in magento frontend?

I have followed require js config to include highchats.js in the cms page app/design/frontend/Namesapce/Theme/Magento_Theme/requirejs-config.js Code var config = { paths: { 'owl':'...
0
votes
0answers
28 views

How can I add critical JS on Magento 2.3.3?

Magento 2.3.3 has "Move JS code to the bottom of the page" function which moves all JS code to bottom of the page. I need some JS code(Seal Verification Code which showing verification icon) not ...
0
votes
0answers
57 views

Uncaught (in promise) ReferenceError: object is not defined on checkout page

JS object is not defined on the checkout page. Already included the script on the checkout page. Exactly the same thing is working on a simple Html page. but creating some issue on magento2.
0
votes
1answer
22 views

Magento2.3: Javascript is not loading in server but working in localhost

I'm facing a strange issue. I have main.js file in my theme (that is extended luma theme), there I have included javascript and jquery of megamenu, add to compare, etc. Now, the issue I'm facing is ...
0
votes
0answers
54 views

Magento 2.2 display swatch image on Product Page

Magento 2.2.2 I have in my view.phtml the following code /app/design/frontend/mytheme/shop/Magento_Catalog/templates/product view.phtml $img1 = $products->getResource()->getAttribute('...
0
votes
0answers
106 views

Disable Javascript Minify Only for Admin Magento 2

I am trying to Disable the JS Minify for admin part only, is it possible to achieve that ? This link How to disable Js merge for admin is for disabling merge/bundling js . But i want the disable the ...