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
2
votes
0answers
106 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
136 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 ...
4
votes
3answers
363 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
125 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
157 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
94 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
72 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
84 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
57 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
18 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
1answer
103 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
63 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
23 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
455 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
445 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
27 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
222 views

Product detail page image not loading on front end

Product detail page images are not loading. The pointer is just spinning. I have read lots of threads. Clear cache, reindexed, change permissions. Finally, I got a problem. but unable to fix it. :-/ ...
0
votes
1answer
44 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
97 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
39 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
74 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
13 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
46 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
154 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
45 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
124 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
21 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
1answer
53 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
141 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
71 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
233 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
42 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
326 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
28 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
48 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
57 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
52 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
18 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 ...
0
votes
1answer
287 views

Magento 2 read more and read less in description product page

I want to add a read more and read less button in the description on the product page. I do not want to cut the entire text and onclick of the read more show another div with the entire content. I ...
0
votes
1answer
40 views

Remove alert.js file from magento 2

I want to remove alert.js file from my DOM. following is the file location "vendor\magento\module-ui\view\base\web\js\modal\alert.js" I tried so many ways in my child theme's default.xml file <...
0
votes
1answer
56 views

Remove annoying calculate button from Magento 2 Bundle Page layout

I have set up a bundle product and its working but can I disable the javascript that forces me to click on calculate every time I use it? I want it to open in "calculate mode". I dont know what Im ...
0
votes
0answers
12 views

Passing data as Javascript variables without caching

I've made some modifications to Magento's swatches via a custom module to display out of stock options on the product page (as non-selectable deactivated swatches, so the user will know that the ...
2
votes
0answers
98 views

Magento2 error after theme upload: Invalid template file

After uploading new theme files (Hebes) to Magento 2.3 installation I receive the following error: 1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file:...
0
votes
0answers
28 views

Magento 1.9.2. - JS and CSS that block the view above the fold

I'm searching the web for a definitive solution to the "problem" that google reports when i test the speed of my site on Google PageSpeed. Magento's JS and CSS block the above-the-fold view and I ...
0
votes
0answers
14 views

I can't disable event FacebookPixel in Checkout page

I have created a module to install facebook pixel on magento. My problem is when I created the disable page view function. It disabled on the url: http://localhost/magento2300/checkout but when I ...