24 votes

How to pass variable to external js in magento 2

There are two ways to include javascript from the template in Magento 2: the <script type="text/x-magento-init"> and the data-mage-init attribute. Either way can be used to pass data to the ...
Aaron Allen's user avatar
  • 8,969
7 votes

Custom form Validation - Magento

There are a lot of classes for data validation: 'validate-no-html-tags' => 'HTML tags are not allowed' 'validate-select' => 'Please select an option.' 'required-entry' ...
Javi Ps's user avatar
  • 183
5 votes
Accepted

Modify existing prototype js validation method

Here is how you can either override an existing validation method or create your own. There is only one js snippet below bc its the exact same procedure for either one. In my example, I override an ...
Shawn Abramson's user avatar
4 votes
Accepted

getElementsByName doesn't work after admin grid ajax request

instead of var checkboxes = document.getElementsByName(chkboxName); try prototype var checkboxes =$$('#billship input[type="checkbox"][name="invoice_ids"]');
Qaisar Satti's user avatar
  • 32.4k
4 votes

magento 1.9.3.2 backend reset password error

I just fixed the problem for my project. For me this looks like strange behaviour of the return Content-type header. My solution is just to patch "app/design/adminhtml/default/default/template/...
ceckoslab's user avatar
  • 837
4 votes

How to extend admin js in magento 2 by mixins

I am curious to know why would Magento won't allow using mixins on such file... any quick explanation about it?
Ezri's user avatar
  • 41
3 votes
Accepted

prototype window pop up document.observe function error. TypeError: $$(...)[0] is undefined

I modified the popup code, this worked for my needs. function addNewPop(id,title,w,h){ win = new Window({ title: title, className:"magento", destroyOnClose: true, recenterAuto:false, ...
Anthony's user avatar
  • 65
3 votes
Accepted

Dynamic text in prototype field validation

I know it's a bit backwards, but you can access the Validation object inside your validation method and then modify it dynamically while you run your test. What you can do is for example, add a new ...
Hydde87's user avatar
  • 146
2 votes
Accepted

Check an ajax response is json or else using prototype js

Find a function which is fulfill my requirement. Function name: isJSON(). just add below two line code and get result var response = transport.responseText; if (response.isJSON(...
Amit Bera's user avatar
  • 77.2k
2 votes
Accepted

How can i upload a file using prototype js ajax call

You cannot sent files via AJAX calls (at least not on all browsers), but you can simulate an AJAX call and upload a file without a page refresh. You can take a look at how the category image is ...
Marius's user avatar
  • 198k
2 votes

Are JavaScript events triggered during the onepage checkout of Magento?

Add the following code in your checkout/onepage.phtml file. This override the core checkout gotoSetion function Checkout.prototype.gotoSection = function (section, reloadProgressBlock) { /*For ...
MeenakshiSundaram R's user avatar
2 votes

Magento 2 - Replace existing Prototype JS with jQuery

First add requirejs-config in Vendor/Module/view/[your_area]/requirejs-config.js var config = { map: { "*":{ MySlider: "YourVendor_Module/js/myslider" } }, paths: { } }...
mrtuvn's user avatar
  • 3,263
2 votes
Accepted

Magento 2 - Replace existing Prototype JS with jQuery

UnderscoreJs library was created when RoR migrate from prototypejs to jquery. You may use it to migrate your scripts. For example Class.create is _.create
KAndy's user avatar
  • 20.7k
2 votes
Accepted

How to extend admin js in magento 2 by mixins

You may not use js mixin for the particular js file you try to override (i.e /vendor/magento/module-sales/view/adminhtml/web/order/create/scripts.js). Also, your require-config.js declaration is ...
Pritam Biswas's user avatar
2 votes

Magento1 Feefo widget js conflict with prototype.js

We had the same error. Seems Feefo is not compatible with the default prototype 1.7 which is included in Magento v1. You could show the widgets using iframes (this may scupper the SEO potential) or ...
Jon Holland's user avatar
2 votes
Accepted

What stopObserving() function is used for - Magento 1.9

Say you have a form input where you are observing the keyUp event. If you wanted to no longer listen to this event, maybe because the value passes validation or is no longer required to validate due ...
Brett's user avatar
  • 1,844
2 votes

How to extend admin js in magento 2 by mixins

Actually, there is another way to extend a class method that worked for me. Example: scripts-mixins.js define([], function () { 'use strict'; if (typeof AdminOrder !== "undefined") {...
Mykhailo Shatilov's user avatar
1 vote
Accepted

Remove Conflict between JQuery and Prototype.js in magento 1.9.1

only noconflict.js this will not work you have to replace variable $ with jQuery add this var jQuery=$.noConflict(); in start of file every jquery related file. and replace every $ with jQuery
Qaisar Satti's user avatar
  • 32.4k
1 vote

Remove Conflict between JQuery and Prototype.js in magento 1.9.1

go ahead and add the contents of noconflict.js directly at the end of your jquery file , this will ensure that it gets executed right after jquery is loaded
Anton S's user avatar
  • 1,244
1 vote

I want to override js function on shipping method section

skin/frontend/{package}/{theme}/js/opcheckout.js //shipping method
PЯINCƎ's user avatar
  • 11.6k
1 vote

I want to override js function on shipping method section

shippingMethod is created in app/design/frontend/base/default/template/checkout/onepage/shipping_method.phtml class ShippingMethid is in skin/frontend/base/default/js/opcheckout.js somewhere at 591 ...
Konrad Siamro's user avatar
1 vote

Ajax.Responders.register's onComplete Executes Before Ajax Complete

onSuccess is not available for Ajax.Responders http://api.prototypejs.org/ajax/Ajax/Responders/ You need to use onComplete and add some extra checks for url and response status Your code can looks ...
DmitryFurs's user avatar
1 vote

jQuery conflict in owlcarousel

If you use a variable $k, then all of your jQuery calls would be with that object. You can use below example of code. You have to modify according your requirements: <script type="text/javascript"...
Deep Zalavadiya's user avatar
1 vote
Accepted

jQuery conflict in owlcarousel

You can add local copy of jquery after following line[skin/frontend/yourpackage/yourtheme/js/jquery.min.js] <action method="addJs"><script>mage/translate.js</script></action> <action ...
Sohel Rana's user avatar
  • 35.6k
1 vote

Uncaught SyntaxError: return 32 - new Date(year, month - 1, 32).getDate();

I don't think you can call the getDate() method directly after the Date constructor. I would replace: return 32 - new Date(year, month - 1, 32).getDate(); With: var myDate = new Date(year, month - ...
Raphael at Digital Pianism's user avatar
1 vote
Accepted

Jquery conflict with elastislide.js and prototype.js

If you use a variable $k, then all of your jQuery calls would be with that object. You can use below code: <script type="text/javascript"> $k = jQuery.noConflict(); $k(document).ready(function(...
Deep Zalavadiya's user avatar
1 vote
Accepted

How to scroll to first error in Magento 1.9 product page?

Edit product template: /app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/catalog/product/view.phtml find: <script type="text/javascript"> //<![CDATA[ var ...
Kaziko's user avatar
  • 51
1 vote

Ajax request not working from validation.js

Your Ajax request url should dynamic. Define a java script which is content request url val at head.phtml var OtpUrl="<?php echo $this->getUrl('RouteId/process/test')?>"; and call this ...
Amit Bera's user avatar
  • 77.2k
1 vote
Accepted

Ajax request not working from validation.js

Please update code ['validate-otp', 'Please enter valid OTP.', function(v) { var url = 'http://127.0.0.1/mage3/index.php/customsect/processing/test?code='+v; new Ajax.Request(url, { ...
Prashant Valanda's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible