0

How can i include my jQuery lib files in magento 2.

Updated

         <block class="Magento\Customer\Block\Account\AuthenticationPopup" name="authentication-popup" as="authentication-popup" template="account/authentication-popup.phtml">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="authenticationPopup" xsi:type="array">
                            <item name="component" xsi:type="string">Magento_Customer/js/view/authentication-popup</item>
                            <item name="children" xsi:type="array">
                                <item name="messages" xsi:type="array">
                                    <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
                                    <item name="displayArea" xsi:type="string">messages</item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </block>

How dependencies of this file is set and how they getting added

1

Assuming you are working with a module, from your layout file like this:

app/code/Learning/Customer/view/adminhtml/layout/default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="Learning_Customer::js/jquery-1.11.0.min.js" src_type="url"/>
    </head>
</page>
  • Using this way you can add the js file but you can not set its dependencies – Shaheer Ali Aug 25 '15 at 7:09
  • plz check the updated question – Shaheer Ali Aug 25 '15 at 7:09
0

app/code/Training/Modulename/view/adminhtml/layout/default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>      
        <script src="Training_Modulename::js/fancybox.js"/>
    </head>
</page>

Add fancybox.js inside view/Adminhtml/web/js/fancybox.js

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.