0

I'm new to Magento. I want to include the following js files in my custom module's layout file in the following location.

app/code/MyVendor/MyModule/view/adminhtml/layout/mymodule_template_custom.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <title>
        My Module Custom Page
    </title>
    <meta name="viewport" content="width=1024"/>
    <css src="MyVendor_MyModule::css/custom.css"/>
    <link src="Magento_Sales::order/giftoptions_tooltip.js"/>
    <link src="Magento_ConfigurableProduct::js/configurable.js"/>
    <link src="Magento_Sales::order/create/scripts.js"/>
    <link src="Magento_Catalog::catalog/product/composite/configure.js"/>
    <link src="Magento_Sales::order/create/giftmessage.js"/>
</head>

But when I take "view page source" I'm unable to see the same js files included.

Kindly help me

Thanks In Advance

  • please show your js file in folder. where you have keep all js file? – Rakesh Jesadiya Feb 15 '17 at 10:32
  • have you ran the php bin/magento setup:static-content:deploy? – Bojjaiah Feb 15 '17 at 10:36
0

You have forgot to add js before js file in your xml file.

Instead of
<link src="Magento_Sales::order/create/giftmessage.js"/>

you have to keep

<link src="Magento_Sales::js/order/create/giftmessage.js"/>

Full js code,

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <title>
        My Module Custom Page
    </title>
    <meta name="viewport" content="width=1024"/>
    <css src="MyVendor_MyModule::css/custom.css"/>
    <link src="Magento_Sales::js/order/giftoptions_tooltip.js"/>
    <link src="Magento_ConfigurableProduct::js/configurable.js"/>
    <link src="Magento_Sales::js/order/create/scripts.js"/>
    <link src="Magento_Catalog::js/catalog/product/composite/configure.js"/>
    <link src="Magento_Sales::js/order/create/giftmessage.js"/>
</head>

Run php bin/magento setup:static-content:deploy command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.