cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Find js of data-action=“add-to-wishlist” in magento 2

Unable to Find js of data-action=“add-to-wishlist” in magento 2

i Want to Find Where js is written for data-action="add-to-wish-list" in magento 2

i saw add-to-wish list data-action many times..

on research i found the action in

Mageto_Wishlit/js/addtowishlist.js

Here is a widget with two functions

bindFormSubmit: function () {
            var self = this;            $('[data-action="add-to-wishlist"]').on('click', function (event) {
                var element, params, form, action;            alert("Hi I am Here");
                event.stopPropagation();
                event.preventDefault();                element = $('input[type=file]' + self.options.customOptionsInfo);
                params = $(event.currentTarget).data('post');                form = $(element).closest('form');                action = params.action;

                if (params.data.id) {                    $('<input>', {                        type: 'hidden',                        name: 'id',                        value: params.data.id
                    }).appendTo(form);
                }

                if (params.data.uenc) {                    action += 'uenc/' + params.data.uenc;
                }                $(form).attr('action', action).submit();
            });
        }

And

_updateAddToWishlistButton: function (dataToAdd) {
            var self = this;            $('[data-action="add-to-wishlist"]').each(function (index, element) {
                var params = $(element).data('post');alert("Hi I am Here");
                if (!params) {
                    params = {
                        'data': {}
                    };
                }

                params.data = $.extend({}, params.data, dataToAdd, {
                    'qty': $(self.options.qtyInfo).val()
                });                $(element).data('post', params);
            });
        },

i have tried to interupt these two events by adding alert but i am not getting any success Need Help

6 REPLIES 6

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

@waqar_ali7 

 

please try the below commands.

 

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

And then check the results.

 

Thanks

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

Hello @Rahul Gupta  thank for your reply

 

i did this already not getting success i check code in pub/static code is exactly what i want but its not working

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

@waqar_ali7 are you using any custom theme or you are checking this in default luma theme?

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

@Rahul Gupta  i am using Magento 2.3.3 CE with sample data and Luma theme, i have no any other custom modules installed other than magento defaults modules

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

@waqar_ali7 so your target is just to find the js which is called on wishlist or you need it for any particular work?

Re: Unable to Find js of data-action=“add-to-wishlist” in magento 2

@Rahul GuptaYes i just want to know which js function is calling on data-post="add-to-wishlist" click