The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

616 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
600 views

Magento 2 Fotorama click event

Is there a way to fire a fotorama click event from a template file? What I am trying to do is have the functionality where, when the user selects an options from the dropdown from the catalog-product-...
1
vote
0answers
476 views

How to remove <script> tag if the device is mobile ? M1

I am trying to remove certain dynamic script tags if the device is mobile. I have something like this to start with: Vendor/MobileDetect/Helper/Data.php : <?php class ...
1
vote
1answer
52 views

Change contact form validation

I would like to do a blur check on the contact form, but it only does the validation on the submit, I would like to know how I make this change. I'm trying like this $j('contactForm').blur(...
1
vote
0answers
519 views

Can't get ajax request post in Magento 2

In my js file i have this ajax request : var url = $(this).closest("form").attr('action'); jQuery.ajax({ type: "POST", url: url, ...
1
vote
0answers
97 views

Magento 1.x way of extending product.js

I recently found myself working with making price updates work in two places on a configurable product page. The previous dev had set up some jquery to try and catch the price updates and apply them ...
1
vote
0answers
81 views

What is the difference between the navigation and menu widgets

I've just noticed Magento 2 has two widgets that sound very similar, the menu widget and the navigation widget. They are both customised versions of the Query UI Menu widget and they both use the ...
1
vote
0answers
58 views

Magento 2 Add Javascript

I have the following code in a custom module for admin backend, which is not running. tinymce.html <textarea class="admin__control-textarea wysiwyg" data-bind=" value: value, valueUpdate: ...
1
vote
0answers
72 views

How to get pop up on button click popup with ajax call

On Shipping method section after select shipping option i want to open pop Up with 2 button submit & cancel on click on submit button i want to check my logic via ajax call
1
vote
1answer
78 views

Making selector available to ui component / philosophy

You'd think that the selector .el in { ".el": { "Magento_Ui/js/core/app": { "components": ..... would be made available to the ui component. Instead, it's just thrown away, ...
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
2answers
1k views

data-mage-init not working on CMS page

If I add this to a CMS page then it pull in the javascript to the page correctly: <script type="text/javascript"> requirejs(['jquery', 'bootstrap'], function (jQuery, jQueryBootstrap) { ...
1
vote
1answer
307 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
5k 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
1answer
218 views

Custom script is loaded before javascript libraries sometimes

This is my requirejs-config.js in theme folder var config = { deps: [ "js/main", ], map: { '*': { 'flexslider': 'js/jquery.flexslider-min', 'typing'...
1
vote
2answers
282 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
151 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
135 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
217 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
0answers
321 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
1k 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
361 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
893 views

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

I have create an extra step in magento 2 checkout page and put custom step after "Review & Payments" step. Now as you can see there is "Next" button on my custom step. I want here "Place Order" ...
1
vote
2answers
862 views

How to get Lazy image like Jet.com

How can I set my logo like jet.com before loading images
1
vote
0answers
52 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
51 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
135 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
743 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
194 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
196 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
265 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
922 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
154 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
745 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
1answer
293 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
302 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
432 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
732 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
182 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
783 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
174 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
343 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
983 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
172 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
116 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
83 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
491 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
227 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 ...