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.

1
vote
0answers
37 views

How to select a shipping method if the default address is present in checkout page in Magento 2?

I need to select the first method rendering in the list as the default selected among the shipping methods in the checkout page for a customer whose default shipping address is pre-populated in the ...
2
votes
1answer
66 views

How to pass variable from phtml and how to get variable in require js file

How to pass parameter form .phtml to require js file Template file <script type="text/javascript"> require(['Namespace_Module/js/custom'], function () { }); </script> JS ...
2
votes
2answers
133 views

How to add custom checkbox with event in customer registration Magento 2?

I'm working on creating a custom checkbox with an event <div class="field tcagreecreateaccount required"> <div class="control"> <input type="checkbox" id="...
0
votes
0answers
37 views

Magento 2.3 - While in backend i get js error “cannot read propery map of undefined” then logs me out of backend

TypeError that is happening and it doesnt happen on a specific page. it happens throughout the backend and then logs me out.
2
votes
1answer
59 views

how to add onclick method in magento2 admin custom module page?

my edit.php file in magento admin custom module $this->addButton( 'approve', [ 'label' => __('Approve'), 'onclick' => 'deleteConfirm('...
4
votes
0answers
43 views

How to create a basic progress bar with ajax, when il click add to cart in Magento 2?

I try to make a basic progress bar with ajax , when I click button add to cart, but I don't know how catch the xhr on console,to put on alert() or prepend()function I follow a video example in ...
1
vote
1answer
69 views

I just implemented Bootstrap 4 in my magento 2.2.5 website. Require.js 166 Error

In my environment implemented Bootstrap 4 in Magento 2.2.5 at first glance it seemed to work. all of my js and css worked perfectly without any error's. But after sometime, I got error: Uncaught Error:...
2
votes
0answers
65 views

Google Chrome is failing in loading require.js files in time

On Magento 2 (ver 2.2.5), with Google Chrome (ver 72.0) I'm getting a wired error I wasn't getting withe previous Google Chrome version (ver 71). When I visit a product page, I get more then one ...
0
votes
0answers
102 views

Magento 2 - js mixin

I am trying to overwrite some methods from my original js file. My original file path is: app/code/vendor/theme/view/base/web/js/file.js. In my file-mixin.js file I want override few things from ...
3
votes
3answers
224 views

css not loading in owl carousel magento 2

hello guys i am trying to use owl carousel in phtml file in console it shows error regarding css Following is my default_head_block.xml file which is a layout file <?xml version="1.0"?> <...
5
votes
3answers
1k views

Custom javascript not working

I'm trying to inject a scroll to anchor javascript globally in Magento 2. More specifically this script: $('a[href^="#"]').on('click', function(event) { var target = $(this.getAttribute('href'));...
1
vote
1answer
62 views

The value you set has already been locked. To change the value, use the --lock-env option

I'm trying to do php -f bin/magento config:set dev/js/enable_js_bundling 1 But I get: The value you set has already been locked. To change the value, use the --lock-env option. What does this ...
1
vote
1answer
137 views

How to use owl carousel using require js in magento 2

Anyone can help me out how to use owl carousel using a custom theme by using require js I have downloaded owl carousel zip file from an official website. I want to use this owl carousel in my block ...
1
vote
1answer
69 views

Uncaught Error: Mismatched anonymous define() magento 2.2.4

Below is the console erros is getting in frontend. Checked .htaccess in pub, pub/static and root all .htaccess are identical to Magento 2.2.4 version. js bundling/minification is enabled and ran ...
0
votes
0answers
57 views

Magento2 : How to disable days and dates in same beforeShowDay function?

In js file how to disable both date and day in same beforeShowDay function To Disable Specific days beforeShowDay: function(date) { var day = date.getDay(); if(disabledDay.indexOf(day) > -...
0
votes
1answer
64 views

Magento 2: Include Product url in custom js file

How to include product url in Custom js file, In Magento2. I am using below code in template file: $_product = $block->getProduct(); $_product_url= $_product->getProductUrl(); echo $...
3
votes
0answers
24 views

js not loading properly in backend product edit while click on show/hide of description field magento 2.2.4 production mode

This issue specific to production mode of Magento 2.2.4. Js is appending in product edit url like : base_url/admin/catalog/product/edit/id/57473/set/12/key/...
1
vote
0answers
45 views

Show magento loader ajax

how can I show the loader only on my div and not on the body during an ajax call ? Can't make it work. Here's my code, I have the show loader and the context but I'm missing something ? <div id="...
1
vote
0answers
16 views

Magento2 : Fire body loader with text/x-magento-init

i have a custom block on my page, that calls javascript via text/x-magento-init and performs some operations so loader should be displayed untill that script will finish its operations. How can i fire ...
1
vote
1answer
25 views

Adding JS code Always showing below footer

I am inserting JotForm JS code in specific CMS Page but it always showing after footer. Even when I add jQuery CDN, it always showing after footer. I have tried head.phtml, header.phtml, CMS page ...
1
vote
0answers
65 views

Magento 2 - problem with mCustomscrollbar.js

Since few days i try to fix issue with my mCustomScrollbar plugin and i got stuck. First of all i i've got library with mCustomScrollbar.js and mousewheel.js in web/js/mCustomScrollbar and my ...
0
votes
2answers
62 views

Getting JS errors on live site [closed]

http://35.178.2.150/rep/india please hit this URL and inspect it, and help me if you can.
1
vote
0answers
18 views

how to download wishlist in excel format in magento 1.9

i want to download my wishlist in excel format without any plugin, currently i'm able to download my wishlist as docx type. Please help.
1
vote
2answers
307 views

Magento 2: check customer logged in by javascript use model

Just wanna to check if customer logged in by javascript use Magento_Customer/js/model/customer. I've included following js file in module: define([ "jquery", 'Magento_Customer/js/model/...
0
votes
2answers
324 views

Magento 2 layered navigation Ajax jquery problem

I am having this problem from Magento 2.2.5 and when upgraded to Magento 2.3 also. I use custom template Layered navigation with Ajax isn't working. I use Amasty one It just refreshes the page and ...
0
votes
0answers
25 views

How to do password validation part without form (Magento 2)

I have a form which has password change functionality, the issue for a change I wrote my own controller and I change the button to type = 'button' from submit. Now how can I validate the password? I ...
0
votes
0answers
135 views

Product detail page image not loading on front end

Product detail page images are not loading. Pointer is just spinning. I have read lots of threads. Clear cache, reindexed, change permissions. Finally i got the problem. but unable to fix it. :-/ I ...
0
votes
1answer
32 views

Pass data between components

Assuming I got 2 components like this: How can I pass data from 1 component to another? In this example I would like to pass some data when I close the modal to "my-component" <script type="text/...
2
votes
1answer
61 views

Cannot export customer list in Magento 2

I was trying to export a customer list to a CSV file in Magento 2 (2.2.7). But every time I try it comes up with a 500 error regardless of how many customers are included in the export. Exporting ...
2
votes
0answers
32 views

How to edit source of the index page in Magento

I am a professional PHP developer, it's been like 2-3 days since I am trying to work with magento. My task is to optimize the index page. Thing is, I can not edit the "actual" source of index page. ...
0
votes
1answer
56 views

Why Magento2 not loading css and js files in local setup?

my root folder .htaccess file RewriteOptions inherit # php -- BEGIN cPanel-generated handler, do not edit # Set the “ea-php71” package as the default “PHP” programming language. <IfModule ...
1
vote
0answers
10 views

Closure Compiler support

It seems there are several performance extensions for Magento 2 but none of them mention Closure Compiler which still yields the best results compared to the current minifier. The extensions which I ...
3
votes
1answer
44 views

Custom field in the form not saving values in to the Database in magento 2.1

I have created a custom attribute for customer using below code. setup/installData.php $customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'samsung', [ 'type' => '...
2
votes
1answer
107 views

Magento 2 How to add external Js in a page

I want to add an external js in my home page. The external js loads a popup form in my home page. I have tried the code in phtml file and also in xml file. In both case the form will appear. But some ...
3
votes
1answer
43 views

Customize Account setting form in Magento 2

In Magento 2, the previous Account Setting edit form has a different layout, like for changing password user has to select the checkbox and then text boxes for password updates pop up, I am changing ...
0
votes
0answers
10 views

How to translate a jas message magento 2

I want to translate this message to english but i can't find a way please help me $("#nbr-pieces-tot").html(nb_prod + chaine_selected+" X "+nbre_pieces_par_caisse +" pièces = "+ nb_piece_tot +' ...
2
votes
1answer
85 views

JS Merge vs JS Bundle which one is better for Google ranking

JS bundling saves page size in MBs but bundled js loaded synchronously. And the browser waits for js download completion. But in JS Merge Magento merges only those js which are required synchronously....
1
vote
0answers
18 views

Magento 2 remove lazy load header cart with items

We are currently developing a new Magento 2.3 store, but we find out that items in the cart in the header, are loaded quite late. When we load a page on frontend, first the entire page loads and then ...
1
vote
0answers
29 views

How can i disable till 1 week next future dates in Magento js Calendar?

I want to allow customer to choose dates after 1 week from current date. Like as today date is 15 Feb 2019 so customer can select dates from 22 feb 2019. I did change js for calendar by adding below ...
2
votes
0answers
75 views

Magento 2.2 x or 2.3 - to bundle or not to bundle

I've read so many conflicting write up's and blogs about whether to "Enable Javascript Bundling" or not. Some say it's slow and some say it's faster when enabled. From what I understand it takes all ...
1
vote
0answers
66 views

CSS and JS merging options is not working on Magento 1.9.2.4

I am simply trying to enable the option of merging JS and CSS on configuration > system > developer and I have cleared the cache and even tried to delete the VAR folder and still having CSS and JS not ...
5
votes
1answer
200 views

Megamenu issue - Clicking menu opens category page for that menu in mobile in Magento2

I need to resolve issue of responsive megamenu for mobile. The issue is when I click on the subcategory to opens its child sub-categories the link gets clicked and gets redirected because of which ...
1
vote
0answers
31 views

JSON.parse: unexpected keyword at line 1 column 1 of the JSON data

I am getting this error in checkout. Below the Shipping Address form, Shipping Methods is stucked on loading. In console it says: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data ...
2
votes
0answers
278 views

Should i use tinymce or tinyMCE in magento 2.3 and also usage for backward compatible

From magento 2.3 i see core team integrated new version of tinymce. It's a good thing. Maybe future they will add more editor for magento. But i have a confuse a bit when to use wysiwyg through below ...
0
votes
0answers
26 views

Magento 2 Add js from my own theme to every page with Miscellaneous HTML

In Content -> Design -> Configuration -> Footer -> Miscellaneous HTML, I can add javascript files like this just fine, <script type="text/javascript" src="http://example.com/myjavascript.js">&...
0
votes
0answers
47 views

Magento2: how to add/remove a form field using javascript

I have created a custom form in admin in which I need to show buttons such as "Add more" and "Remove". The scenario is exact that which is discussed here: https://stackoverflow.com/questions/...
1
vote
1answer
44 views

Programmatically add image to media gallery in Magento2

I am looking at this article on the Gallery API in Magento2. I am testing the code samples in my browser var api = $('[data-gallery-role="gallery"]').data('gallery'); However, this returns undefined....
0
votes
1answer
14 views

Magento 2.2.7. Best way -according to the Magento guidelines- to apply some custom javascript to specific products

At app/design/frontend/Custom/Theme/Magento_Catalog/templates/product/list.phtml I'm trying to apply a javascript for certain products (not all of them) as follows: <?php foreach ($...
0
votes
1answer
42 views

Show and Hide Product Grid in custom module Magento 2

I have created a drop down field. When I select 1 option from field I want to show the another field and along with that I want to hide product grid. Same as when I select 2nd opinion, I want to show ...
0
votes
0answers
15 views

Magento 2 implement Readmore.js from jedfoster

I want to implement Readmore.js to our Magento 2 store. See: https://github.com/jedfoster/Readmore.js For some reason it does not work, maybe due to conflict jQuery with default Magento 2 code? Is ...