Questions tagged [jquery]

Denotes questions related to the use of jQuery library in Magento.

Filter by
Sorted by
Tagged with
25
votes
2answers
39k views

How to use jquery library in Magento 2?

I am creating a Magento theme where I need to include jQuery. When I add this <link src="js/jquery-1.7.1.js"/> in head. It is working but Magento javascript functions are not working. How to ...
17
votes
3answers
6k views

Magento 2 add custom product attribute validation from install script

[ 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'XXXX', 'input' => 'text', 'frontend_class' => 'validate-greater-than-zero', 'source' => '', 'global' =>...
16
votes
4answers
19k views

Adding a jQuery Library to Magento 2

How can a third party developer add a jQuery library to Magento 2? While Magento 2 includes a version of jQuery in their frontend themes, the jQuery object is not immediately available in the global ...
12
votes
2answers
12k views

How to add bootstrap.js in magento2

I m trying to include bootstrap js on my magento2 theme. But the problem is when i include bootstrap js on my theme. That time console is giving error that bootstrap require jQuery. Then how can i ...
12
votes
1answer
6k views

magento2: how validation work in magento2

In magento1 we can check validation like this: var formToValidate = $('form-validate'); var validator = new Validation(formToValidate); if(validator.validate()) { // Here we can code ...
10
votes
5answers
22k views

How to add Jquery in Magento?

In my current project in about us page I need to add tabs to switch between different section I know this can be done by Jquery tabs but I don't know how to do this when integrating with magento.
9
votes
2answers
6k views

How to create a Magento 2 Modal popup that cannot be closed?

I'm trying to create a modal popup that cannot be closed. It has a button that takes you to the next page by clicking on it, but I don't want users to be able to close it. The modal popup can be ...
8
votes
1answer
882 views

What does $$ in javascript of Magento 2 mean?

In some core Magento modules I see the $$ signs used constantly when selecting an element. For example, in just 10 lines of code I have the following different selectors: $('selection-apparently-a-...
7
votes
2answers
2k views

Add jQuery Datatables in magento 2

I am trying to use the jquery DataTables in magento-2 frontend using the requirejs. I can see the datables.min.js file in the net panel, but somehow it give the following error. My reuirejs-config....
7
votes
1answer
3k views

$(…).swMegamenu is not a function [closed]

I'm using Smartwave Porto theme for my Magento 2 website, when I load my website for the first time in browser console it shows no error at all, but every time I refresh the browser page by pressing ...
6
votes
4answers
13k views

how to implement Loader widget in magento2

I want to implement loader widget in magento 2, In my form i have placed one button <div style="display:inline; float:right; width:100%; margin-bottom:5px;"> <button style="" class="...
6
votes
2answers
4k views

How to close modal popup by clicking outside the modal-content in Magento 2

I have created a popup successfully by using Magento 2 modal code as i added below but now i want to close the popup even customer click on outside the pop-up or blur area. Is there any existing ...
6
votes
3answers
6k views

Magento 2 - Ajax is not calling Controller

I tried to make a simple ajax-call to my controller. Somehow I don't get a valid response. MyCompany/MyModule/Index/GetAjax.php namespace MyCompany\MyModule\Controller\Index; class GetAjax extends ...
6
votes
2answers
3k views

How to wait until text/x-magento-init has loaded the options

It seems to me that text/x-magento-init returns options async: <script type="text/x-magento-init"> { "*": { "component": " <?php echo "test" ?> " } ...
6
votes
3answers
314 views

How to add on scroll animation in magento 2 using AOS (Animation On Scroll) Jquery?

I have tried to add on scroll animation in my Magento 2 cms page. I used AOS Jquery for that. I have added the js and CSS file and initialize AOS through cms page but It will shows Uncaught ...
5
votes
3answers
14k views

Magento2 : ReferenceError: jQuery is not defined

I am trying to add custom jquery code into my module but it is not working. app/code/Custom/Module/view/frontend/web/js/my.js jQuery.noConflict(); jQuery(document).ready(function(){ alert('ok'); ...
5
votes
2answers
6k views

How to add js libraries that require Jquery to magento 2 using requireJs

I am having a bit of strange behaviour with Magento 2 require. What I trying to do is to use glide.js to load carousel image. I create custom.js and here is my code. require(['jquery', 'lib/glide'], ...
5
votes
2answers
4k views

What are the advantages to magento using Prototype

From what I have been able to see jQuery appears to be the js library of choice in nearly every web system/framework/cms. It also seems to be a more intuitive and powerful library but that is ...
5
votes
2answers
2k views

My js file is not loaded in Magento 2

My steps: 1) Load my file slider.js to: app/design/frontend/Vendorname/default/web/js. 2) Create requirejs-config.js to: app/design/frontend/Vendorname/default var config = { paths: { ...
5
votes
2answers
5k views

Issue with jQuery usage in Magento 2

Currently I have a custom block loaded almost last on the page containing: <script type="text/javascript" src="/test.js"></script> This script is pretty much the usual stuff, just ...
5
votes
2answers
753 views

How to trigger self.openFullScreen() function into my custom jQuery in Product details page

If we click on product image in the product details page, gallery full screen is coming to see the images in full screen. I am trying to get the same functionality when click on my string Quick view ...
5
votes
1answer
210 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 ...
5
votes
0answers
465 views

How to apply custom validation in Magento 2 checkout Shipping Address form?

I want to apply some custom validation on shipping address form of Magento 2 Checkout. Normally i do it with JQuery but don't know how to apply it in Magento 2. The validation i want to implement are ...
4
votes
2answers
2k views

What is data-post, data-action in magento 2? Can anyone explain wishlist functionality?

Can anyone explain below code? How did it work? Is there any alternate way to do? <a href="#" data-post='<?php echo $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($...
4
votes
2answers
3k views

How to pass phtml variable in js file in magento2 [duplicate]

This is my phtml file .... <?php $currentCategory = $block->getCurrentCategory(); //echo $currentCategory; ?> I want to set $currentCategory value in js file and display in alert ......
4
votes
2answers
526 views

Magento 2 : How to call text/x-magento-init on Ajax success

I am in need to trigger some script with "text/x-magento-init" on ajax call but I am unable to do so. trigger('contentUpdated') contentUpdated is also not working in my case. I am using ...
4
votes
2answers
5k views

Magento2 adding 3rd party jQuery files to module

I am trying to add in some 3rd party jQuery code to my Magento2 module. I want to have my own custom js file that will use the 3rd party code. Before I was adding the code into the header instead of ...
4
votes
1answer
3k views

Unable to use jQuery

Alright, I am trying to do a very simple thing: use jQuery in my myScript.js file. I'm on Magento 1.9.0.1. The theme I am building is based on the built-in rwd theme, which by default loads jQuery 1....
4
votes
1answer
819 views

magento 2 Add to cart popup is not working after load the product using infinite ajax scroll [closed]

I have used infinite ajax scrolling on product listing page.Its working but there are one issue. Add to cart popup is not working after load product using infinite ajax scrolling. Please check ...
4
votes
1answer
992 views

Pass jQuery value to Observer in Magento 2

I want to pass my custom_price changed via jQuery to my Observer in Magento 2 to have the correct price in my cart. My /Observer/CustomPrice.php: <?php namespace Vendor_Name\Module_Name\...
4
votes
1answer
817 views

Magento 2 Pattern Library — Date & Time Selectors

I would like to implement the "Horizontally Stacked Time Range Picker" from the Magento 2 Pattern Library into an admin form input http://devdocs.magento.com/guides/v2.0/pattern-library/getting-user-...
4
votes
1answer
1k views

How to Extend and initialize a JS Widget with Proper Custom Namespace / Replace Existing Widget

I want to modify the mage.catalogAddToCart JS widget of Magento 2. According to http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html I have to do a $.widget('foobar....
4
votes
2answers
74 views

Menu that open by itself after clicking on the link of a parent category

When I click on parent category, the page load but the menu re-open if the pointer of the mouse is still present. What do you recommend so that the menu does not re-open immediately ? I found PHP of ...
4
votes
0answers
50 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 ...
4
votes
0answers
99 views

Knockout.js in magento2

How to change the jquery into ko? define([ 'jquery' ], function ($) { "use strict"; $.widget('xxx.homePage', { options: { bindSubmit: true, ...
4
votes
1answer
1k views

Magento 2.2.1 Checkout page broken and Js fail to load error

I have installed Magento 2.2.1 and set up my custom theme but checkout page looks broken and consoles showing errors: Not sure how to resolve this issue. Need help how can this be resolved. How ...
4
votes
1answer
167 views

Magento 2.1 : Calendar Frontend

I have some data on front-end , which I want to show on specific days in the calendar. I got this code to show the calendar on the front end . <?php $a = 'some text'; $b = 'some ...
3
votes
3answers
11k views

jquery not defined error in magento 2

I am trying to bring banner scroll in magento2. I am using owl carousel for this purpose. Everything have done and implemented and is showing in firefox without any errors. But when checked in chrome, ...
3
votes
7answers
898 views

jQuery not working for custom checkbox on checkout page

I am looking to create a custom checkbox field on the checkout process that a customer can click to define if they are a business customer or a consumer. To do so I made a module with the file ...
3
votes
1answer
5k views

Magento 2: How to add popup on button click in admin?

Can you explain how to add popup(modal window) on button click in the adminhtml? I already create some phtml <div id="messages"> <div class="messages"> <?php foreach ($this->...
3
votes
2answers
943 views

Block with jQuery autocomplete in checkout page

How can I add jQuery autocomplete to checkout custom block? Part of my js file code: if (...) { $(".hello").not(".red").hide(); $(".red").show(); var availableTags = [ "ActionScript"...
3
votes
5answers
4k views

jquery fancybox for magento 2

Its working in my localhost, but when use same code in magento 2 its not working any suggestions please <!DOCTYPE html> <html> <head> <title>fancyBox - Fancy jQuery ...
3
votes
2answers
3k views

On hover instead of 'click' for mini cart and top account buttons in Magento RWD theme

Where do i have to change the jQuery functionality to show the drop downs from the 'mini cart' and the 'top-account' on hover instead of click on the desktop versions? Thanks!
3
votes
1answer
11k views

Magento undefined jquery

I've added jquery 1.8.2 to both my page.xml file and the corresponding directory.. however i am still getting multiple Uncaught ReferenceError: jQuery is not defined errors. Jquery no conflict has ...
3
votes
1answer
3k views

Conflict with using JQuery in Magento [duplicate]

I want to use JQuery in magento. When I included JQuery in the code, Prototype is throwing errors at this line. element.attachEvent("ondataavailable", responder); Can anyone help me?
3
votes
2answers
3k views

Custom AJAX discount-form not processing coupons

Running Magento 1.9.0.1 CE I've created an AJAX version of the discount-form used in Magento to process coupons in Magento with the help of this tutorial: http://www.lelandcope.com/2012/04/how-to-...
3
votes
2answers
4k views

Magento2 : Getting so many error js error

Getting so many js errors. Please help me how can I fix it. I did a lot search and tried given the solution. The site is in developer mode. require.js:166 Uncaught Error: Script error for: Magento_Ui/...
3
votes
1answer
1k views

Call to a member function getAccountNo() on null Magento 2

I'm extending shipping method section in checkout page, and it's showing well. But it's throwing error while clicking next button after filling shipping address and shipping method information in ...
3
votes
1answer
753 views

Add class to the radio buttons

I have a radio button in the Product View page at the custom options, this contain Hide and Show. Is there any way to add a class for each option? I need to hide everything that is under this field ...
3
votes
1answer
495 views

Edit jQuery to Change Color of Menu

My main landing page shows different images when different categories are hovered (using jQuery on my CMS page). I also want to tie into this and tell it to also change the color of the 'MENU' icon, ...