Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
3 answers
3k views

Uncaught TypeError: $el.ColorPicker is not a function Magento 2

Magento ver. 2.0.18 I created a custom module in backend there is color picker options. for this i used this link color picker answer of @EmizenTech it works perfectly but some time it gives and if ...
1 vote
1 answer
2k views

Magento2 : Save Button Not Working in Admin Form Custom Module

I am Working on A magento 2 custom Module i have a Form as well a Product Grid in my form so i created tabs using block but Whenever i click on save button gives me Javascript Error TypeError: $....
16 votes
6 answers
32k views

How to get the base url from a JS file?

I want to retrieve a base URL and append it with my module controller link from a JS file, so it's impossible to use a block to get the base URL. So far I've done this: define([ 'jquery', 'mage/...
1 vote
1 answer
527 views

Is it possible to load data from the server using a HTTP POST request within a Magento Module js file?

Is it possible to load data from the server using an HTTP POST request within a Magento Module js file? File located in app/code/MyVendor/myCustomModule/view/frontend/web/js/mycustom.js Example ...
2 votes
1 answer
13k views

How to add JS messages from custom module?

How do I add messages using Magento 2 Ui messages to page via javascript from a custom module? I have found a file in Magento/Ui/view/frontend/web/js/view/messages.js that appears to be responsible ...
2 votes
1 answer
4k views

Check If JQuery Is Already Included In Head

I want to check if jQuery is already included on the page. I have seen several methods and finally settled on the following: if ( (typeof jQuery === 'undefined') || !window.jQuery ) { document....
0 votes
1 answer
443 views

How to avoid JS minification in an external file add via requirejs-config.js?

I have a custom module called Quicklink it has its own JS files and external JS files too, I've added an external JS from a third-party CDN, but when I enable the JS minification in a Magento 2 clean ...
4 votes
3 answers
5k views

Is there a some solution to use npm packages within a Magento 2 module?

The main idea - don't keep JS files which belong to some NPM packages in a module repository? Maybe someone have some solution of thoughts.
0 votes
2 answers
677 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
2 answers
908 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 ...
1 vote
0 answers
79 views

Should I be integrating Babel with the frontend javascript in my Magento2 module?

I created a magento 2 module which is using mostly javascript. I want to know what is best practice for implementing backwards compatibility across older browsers in magento2.
1 vote
2 answers
87 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
1 answer
365 views

Magento: addEventListener on change radio button not working using requirejs

Here everything works fine just one issue is there, it doesn't the value and id of input radio fields, So I think domReady addEventListener is not working here. Help is really appreciated TIA This is ...
0 votes
1 answer
175 views

Require JS script implementation issue

I am trying to implement the SurveyJS library into my page but it doesn't seem to work at all and I keep getting "Survey is undefined" whenever I call the Survey object methods, as detailed ...
0 votes
1 answer
663 views

Magento 2 - Custom Module JS error

I am trying to add custom js file using my custom module. But getting below error in console. Uncaught ReferenceError: Plyr is not defined DevTools failed to load SourceMap: Could not load content ...
0 votes
0 answers
57 views

Store external API expire time in Custom Module

I use ajax to get the access token from the external API. How can I store the expired time across the site and the ajax only call again when the session expired? test.js /helloworld/index/display is ...
2 votes
3 answers
3k views

Magento 2: Adding JS from module

I have a module, and I want to add a javascript generated in the module at the frontend footer. The javascript has to be built dynamically because it depends on server variables. I've thought of a ...
1 vote
0 answers
22 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
1 answer
481 views

Magento 2 - Missing js files in a certain store view

In Magento 2, is there a way to disable a module for a single store view only in front-end, like Magento 1? Because that's what happened to me. I have this module named Vendor_XXX that loads several ...
0 votes
0 answers
147 views

Adding custom JS to existing module causing errors

So I've been trying to add some custom javascript to a module, however when the JS has added it works fine in itself, but it causes a lot of errors for a lot of different scripts, and I can't figure ...
2 votes
2 answers
509 views

Magento2 : I am getting this error when i upload two custom module and css and js file

I am getting this error on my live site as production mode and I uploaded only two custom module and js and css and two overwrite file in our theme.Below share error as warning showing I apply all ...
3 votes
1 answer
213 views

How can i add a custom javascript module to custom module?

Hi this code is working perfect without magento. <script src="flipbook.js"></script> <script src="jquery.js"></script> <script> $('#side').FlipBook({ pdf: '...
0 votes
2 answers
2k views

Integrate js with button on uiComponent xml

I have the following custom form in my admin html and I have tried to insert a javascript function on my custom button click but the page being in a infinity loading loop. view/adminhtml/...
2 votes
2 answers
9k 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: |-...
1 vote
0 answers
699 views

Magento 2.2.4 Implementing Bootstrap 4 Carousel to Homepage | JS seems to not be functioning

I've been trying to get the Bootstrap 4 Carousel to work on my homepage and I've been facing an issues that seems like the JS may not be functioning. This is the way that I went about doing so. I ...
1 vote
2 answers
59 views

Adding a JavaScript Module to the homepage

I've followed the DevDoc on How to Add a JavaScript Module (Magento 2.2) and it works fine. However, I can't get it to work on my Magento site homepage. I added /app/code/Learning/Js/view/frontend/...
1 vote
0 answers
41 views

need the CMS path directive for a app/code module folder

i added my own module under /app/code/my/module/ , activated it and put a java script under /app/code/my/module/view/frontend/web/js/myjs/myjs.js it works so far. The javascript is called within a ...
1 vote
1 answer
2k views

Add script in header in checkout page

I want to add some custom JavaScript in the header of the checkout page. I tried to follow the layout structure.. I created a module and places my custom JS file is in app/code/Roman/hello/view/...
1 vote
1 answer
1k views

Magento 2 create module block

I want to define a new phtml block in the head of my module: I try to add something like this in my app/code/Custom/Module/view/frontend/layout/default.xml file: <?xml version="1.0"?> <page ...
4 votes
2 answers
161 views

Issues on create Magento 2 module

I create a module for Magento 2 to add a custom javascript to the theme head but my custom js file is loaded in front off all javascript files and this come with the error: ReferenceError: jQuery is ...
1 vote
1 answer
280 views

Magento 2 - Create simple module

I try to learn how to create a simple module in Magento 2. I create one but I have a lot of errors. If anyone can help me with a sample. How I can create a simple Magento2 module. This module must ...
0 votes
1 answer
664 views

Magento 2: How to add a custom JS to frontend module? [duplicate]

I'm building a module and I need to load Javascript that must be generated in my module (NO theme) to the shop frontend. Then, when a user enters on the web, the module has to generate js and inject ...
1 vote
1 answer
601 views

How can i run a javascript just one time in phtml in Magento 2

I have a GTM script for login in Magento_Customer/templates/account/dashboard/info.phtml <script> dataLayer.push({ 'events':{ 'event':'login', 'category':'login', '...
1 vote
1 answer
2k views

Why is only consol.log working?

I successfully added a JS file to my page and every console.log is working okay. Unfortunately no other function is working. This is how my file looks like. require([ "jquery", "jquery/ui", ...
4 votes
1 answer
14k views

window.checkoutConfig Javascript (usage)

It seems that Magento 2, with the default theme, has a JS object window.checkoutConfig which has all the cart information, and is updated when you change the cart. Is it safe to assume this will be ...
3 votes
1 answer
1k views

How to properly override a core JS file in Magento2

We are attempting to override the behavior of Bundle Products in Magento2, specifically, to enable user defined quantities for Checkbox type products within the bundle. We have written an extension, ...
1 vote
1 answer
2k views

Magento2 rewrite javascript file from a core module in a custom module [duplicate]

I have created a custom module that uses the UI component <uiComponent name="product_listing"/> Basically, I want to create a javascript file in my module that rewrites/overrides only the ...