I have been struggling to find a correct way to implement css and js for my template file, which lies in M2's backend. I put a file named default_head_blocks.xml to implement fullCalendar's css:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/fullcalendar.css" />
        <css src="css/fullcalendar.print.css" media="print" />
    </head>
</page>

I don't really know if this is okay or not. Also, requirejs file mapping is quite tricky, at least for me, to implement. The offical devdocs on this is not very helpful. Is there a way to do these with least pain possible?

share|improve this question

You need edit your layout to:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <head>
    <css src="Namespace_YourModule::css/fullcalendar.css" />
    <css src="Namespace_YourModule::css/fullcalendar.print.css" media="print" />
  </head>
</page>

This location of .css file: Namespace/YourModule/view/adminhtml/web/css/fullcalendar.css

share|improve this answer
    
Thank you for the answer. Could you show me how to implement a custom js file for template? – Hau Pham Dec 8 '15 at 15:59
    
@Hau Pham, answer is mentioned at magento.stackexchange.com/questions/86527/… – Praful Rajput Dec 9 '15 at 6:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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