Skip to content

How to add Custom JS in admin side?

I want to add custom JS on product edit page in admin side. After doing some R&D, i found a solution but that didn’t work. What I have done so far,

app/code/Vendor/Module/view/adminhtml/layout/catalog_product_bundling_tags.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="Vendor_Module::js/catalog_product_bundling_tags.js"/>
    </head>
</page>

app/code/Vendor/Module/view/adminhtml/web/js/catalog_product_bundling_tags.js

require([
    'jquery'
], function ($) {
    'use strict';
    $(document).ready(function () {
        alert("Hey");
        console.log("Hi I am coming from sonybundling");
        let bundlingTags =  $('input[name="product[bundling]"]').click(function() {
            console.log("bundlingTags ===> ", bundlingTags);
        });
    });
});

But when i load the page it couldn’t reflect.
Kindly guide me where I am doing mistake ?