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.

739 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
3answers
1k views

My javascript doesn't run in a custom magento1.9 module

I try to use javascript for a dropdown list I've implemented into a grid as shown in the image. The renderer I use for this dropdown list is like <?php class ...
1
vote
1answer
381 views

Multiply subtotoal price in minicart

I want to show two subtotal prices in the minicart. The plan is to multiply the subtotal price and print it next to the original subtotal price. The price is printed by knockout in the html file ...
1
vote
1answer
666 views

Magento won't create minified JS files

I switched my Site to production mode and enabled JavaScript minification, bundling and concatenating in the backend, expecting Magento to correctly create the .min.js files - It won't, though. First ...
1
vote
1answer
8k views

Unable to resolve the source file for error in custom theme?

I am working on magento version 2.1.3 and have a custom theme shoppersbay. For some js files it gives error like Unable to resolve the source file for 'frontend/Smartwave/shoppersbay/en_US/...
1
vote
2answers
360 views

Magento 1.x search product by specific value in http queryString

Been trying to search how to search item in magento 1.x to return JSON output when requesting something like. www.site.com/api/rest/product?desc=Dress&color=black Been to their doc and the ...
1
vote
0answers
161 views

Uncaught Reference Error

I'm getting this error message after an update that the developer of the plugin performed and it seems to be completely broken now. Is there a way I can fix this error myself? Uncaught ReferenceError:...
1
vote
1answer
158 views

How to add js libraries to Magento 2 extension via composer?

I'm wondering is there a way to add third-party js libraries to Magento 2 via Composer? The main idea of this is to separate our modules from those dependencies and to have them required via Composer ...
1
vote
1answer
232 views

Magento + RequireJS - How to use non-AMD custom javascript with jQuery?

First off, I made a custom javascript file, main.js. Quite simple; it's just this: $("#testp").text("Hello!"); #testp is in one of my phtml files, with just <p id="testp">Hello World!</p>...
1
vote
1answer
341 views

Magento 2 infinite scroll issue

I am using a magento 2 custom infinite scroll module. When I scroll down ajax request initiate and response come with new page content . But this response not updating on current content . I checked ...
1
vote
2answers
2k views

Magento 2.1.6 - Extending the dropdownDialog (lib/web/mage/dropdown.js) not working

I am trying to extend the default dropdown.js of Magento 1) Created a new JS file at app/design/frontend/<vendor>/<theme-name>/web/js/mage/dropdown.js define([ "jquery", "jquery/...
1
vote
0answers
455 views

Pricebox.js Issue Magento 2

I'm having an issue with pricebox.js/configurable.js and configurable products. They are used in quickview and on individual product pages. The first error I get is a console error calling a ...
1
vote
0answers
1k views

How to move “Place Order” button from “Review & Payments” to custom step in Magento 2 checkout?

I have created an extra step in Magento 2 checkout page and put custom steps after the "Review & Payments" step. Now as you can see there is the "Next" button on my custom step. I want here the "...
1
vote
2answers
993 views

How to get Lazy image like Jet.com

How can I set my logo like jet.com before loading images
1
vote
0answers
53 views

How to add class to javascript document.write & shorten date format?

<div class="shipout"> <p style="margin:0;">Delivery: FAST & FREE</p> <script> Date.prototype.addDays = function(days) { var dat = new Date(this.valueOf()); dat.setDate(...
1
vote
1answer
54 views

I want to add jquery validation to my form ! How can i do it?

I am using magento's inbuilt luma theme to practise and i am not able to understand where exactly is js written how is the flow ? This is my basic view page. And is working fine i want to add jquery ...
1
vote
0answers
166 views

Magento 2 - Using KOJS template for filter component?

On the same page I have several custom product grids with above them a filter toolbar. To simplify the case : <?php foreach ($grids as $id => $grid): ?> <div class="container"...
1
vote
0answers
778 views

Magento 2 : How to Add Date Validator on Custom Input Form Js File

I have created a custom input on the checkout page, I want to add date validator from js but I can't. I already tried this custom js: $( "#co-shipping-method-form" ).validate({ rules: { ...
1
vote
1answer
216 views

1.9 - Can't upload image

I have a trouble with upload images in Magento backend. I think there is a problem with <?php echo $this->getJsObjectName() ?> in app/design/adminhtml/default/default/template/media/...
1
vote
0answers
48 views

Execute custom JS on 'Add to cart' completion

I'm currently trying to implement a very simple JS that should take the product name, quantity and price and store it in an json array so I can use it later on as part of the basket abandonment ...
1
vote
0answers
2k views

How to add js file to footer end of body in magento2

I want to add to footer from this code <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="empty" xsi:noNamespaceSchemaLocation="../../../../../../...
1
vote
1answer
303 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
1answer
279 views

Inline small jss css

GTmetrix advises I inline these <action method="addJs"><script>mage/translate.js</script></action> <action method="addJs"><script>lib/ccard.js</script></...
1
vote
0answers
975 views

Magento 2 How to flush javascript cache?

I rewrote the code in validation.js. It was successfull,the new text has appeared on the site and now i want to change it again but this time its not changing on the frontend. I tried to flush cache,...
1
vote
0answers
162 views

Magento 1.9 Calendar not displayed on customer registration page

I am using magento 1.9 for my website. I have enabled Javascript calendar in magento admin, but it is not displayed on customer registration page for Date of Birth field. How should I enable it?
1
vote
0answers
762 views

How to initialise a carousel and use Knockout observables in the same JS file

I'm experimenting with Require JS and Knockout JS in Magento 2 and I've ran into a strange problem where I can't use Knockout JS and initialise a carousel in the same JS file. The carousel works fine ...
1
vote
0answers
3k views

How to use Ajax in magento 2 custom module

I am working on one custom module and i need product load when any ID is clicked. Loading is handle by ajax. I am not aware of ajax in Magento 2. Can anybody give me small demo of ajax in Magento 2 ...
1
vote
1answer
306 views

3rd party jQuery JS and custom JS together

I read many many stackechange threads and internet pages, and still do not get how to do such a simple task as using Javascript. I try my luck... I use 3rd party jQuery Plugins (bxslider, modaal) I ...
1
vote
1answer
322 views

de-select a selected radio button on click

HTML code: ..... <input onclick="removeAttr(i)" name="autoselected[]" value="i" class="radio" checked="checked" type="radio"> .... function removeAttr(i) { preSelected = $$('[input[type=...
1
vote
0answers
549 views

can't get jQuery's ajaxComplete working

I can't get jQuery's ajaxComplete to work. I'm thinking it's because the ajax call is being initialised by Prototype? But how can I check when any ajax call This is basically the code I have: ...
1
vote
0answers
827 views

Problem with loading Javascript in Magento 2 from history

On our Magento 2 new webstore there is a problem with loading javascript from history (with F5 or new tab). This problem occurs mostly in Microsoft Edge Browser. Sometimes, my code loads fine, but ...
1
vote
1answer
203 views

MAGENTO 2 - How to trigger function on the template after admin save?

I'm wondering it's possible to call (trigger) method on the frontend when admin changes something in backend (admin panel) Suppose that I have banner which has image with 24h cache-validation time. I ...
1
vote
0answers
823 views

Uncaught TypeError: Cannot read property 'value' of null(…) on Onepage checkout page

I can't progress to the payment step when I click continue: UncaughtTypeError: Cannot read property 'value' of null : getting error on click continues button. Can someone assist me, please?
1
vote
0answers
194 views

How to change inline js

<li class="buttons ajaxlogin_actions"> <button id="ajaxlogin_button_send" name="ajaxlogin_button_send" title="<?php echo $this->__('Login') ?>" class="...
1
vote
0answers
387 views

Magento2 cant find …min.js

Afer content deploy php bin/magento setup:static-content:deploy de_CH php bin/magento cache:clean in direcrory pub/static..../js created ...min.js files but magento on frontend try to load not min ...
1
vote
1answer
1k views

styles and js not found 404 magento2

I installed magento2 on openserver created my custom theme developer mode is enabled content deployed When i try to load home page browser showed errors in pub/static i have only wNumb.min.js and ...
1
vote
0answers
178 views

Load specific step in One Page Checkout

A link is sent to a customer to complete the payment on payment pending. So the link redirects the customer to the one page checkout. Where all the details are filled in through the quote of the order....
1
vote
2answers
122 views

Magento 2 Default JS doesn't load proper

Magento 2 is broken in admin panel and add to cart does not work. I have checked both pub/static/frontend/Magento/Theme/en_US/mage/dropdown.js and pub/static/adminhtml/Magento/backend/en_US/...
1
vote
0answers
87 views

Overwrite a modules JS files with theme

I've been looking over the Magento 2 Docs for using custom JS and have been trying to add a modified version of 'configurable':'Magento_ConfigurableProduct/js/configurable' to my theme directory so ...
1
vote
0answers
1k views

ReferenceError: Flex is not defined

I am receiving this error with an extension. I think this is related to the last patch 8788, anyone know how to solve it? the error points me here var uploader = new Flex.Uploader('...
1
vote
0answers
528 views

How to disable auto collapse in mobile menu?

In mobile menu of Magento 2 when we click any child item of a parent, the parent collapse [see the image] what can i do to disable this behaviour. Demo: http://magento2-demo.nexcess.net/contact
1
vote
0answers
228 views

Magento 2 : How to merge JS for frontend?

I want to merge all js request and for this I am using Merge JavaScript setting of Magento and set it to yes. But still lots off js request in browser which are not merged. How do I merge all these ...
1
vote
0answers
452 views

Can't get my ajax request to call controller

I'm trying to send information from the view (js) to the server. I'm trying this with the JS request: $.ajax({ type: 'POST', url: 'php_file_in_controller/Main_Class_Name', data: data, ...
1
vote
0answers
98 views

How opinionated is magento2 frontend(JS)?

I hope this question makes sense, there is a chance it doesn't. I am looking into creating a custom checkout module for Magento2 and as a part of it i am evaluating JS frameworks. After evaluating ...
1
vote
1answer
994 views

Magento 2: Adding external CSS and JS to only one content page, and use jquery functions inside the content

I am trying to add some dynamic function to one content page of a Magento 2 site, but didn't manage to do it. Here is what I thought: 1) Adding the external javascript files at the "Layout Update XML"...
1
vote
0answers
306 views

css and js should have relative path in page source - magento2

I have one request that is I need to change all the css & js path from absolute to relative in page source. Please refer the screenshot for your easy reference. here I want to change all the css ...
1
vote
0answers
121 views

Saving a page/static block triggers an tinymce error and I can´t switch from HTML to text

I have a up to date Magento System. But for some reason when I am in the backend and want to edit a page or a static block, I cant switch from the HTML view to the text/visual view. If I click the (...
1
vote
1answer
861 views

Magento 2 How to call a ajax function in x-magento-init type javascript?

It seems cannot use jquery lib inside the x-magento-init type javascript. How to call a ajax function in x-magento-init type javascript? Thanks
1
vote
0answers
50 views

multiple coupon code apply on magento cart

I have been working for 2 days for applying multiple coupon on cart I know there are modules which are available for that. But i don't want to use it. I want some custom code so that i can apply more ...
1
vote
0answers
100 views

Magento 2 Script tag error

I'm having an issue with Magento not processing script tags correctly: This code: echo $this->getChildHtml('addthisJs'); adds this script tag: <script type="text/javascript" async src="//s7....
1
vote
2answers
508 views

Swap image on hover

Galera, would like to switch from one outfit to another over the mouse, I made one code but is a bit buggy. I would like this site here: https://amaro.com/moda-feminina/blusas Mine is this: duetju....

1
4 5
6
7 8
15