Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee 5 posts 76 karma points
    Aug 06, 2018 @ 09:43
    Lee
    1

    Macros using Client Dependency Injection inside Grid View

    Hello All,

    I have a strange issue when using Macro's inside of a grid view. I am currently trying to optimize my Css and Javascript and only load the bits I need for the page. I have a Macro setup as follows:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using ClientDependency.Core.Mvc;
    @{
        Html.RequiresCss("/css/Vehicles.css");
    }
    <div class="grid-x align-center-middle check-in-advice-block foot">
        <div class="shrink cell">
            <div class="check-in-advice-time-roundel text-center">
                <h5 class="check-in-advice-time">Check-in-foot-time-minutes</h5>
                <h5 class="check-in-advice-time minutes">Check-in-minutes</h5>
            </div>
        </div>
    </div>
    

    As you can see I am trying to Inject my Vehicles.css to the macro, however when i add this via a Grid View inside Umbraco. The CSS does not get added to my combined CSS.

    If I add the reference to the View that contains my Grid View, It will add my Vehicles.css to my combined css. However this will add it to all my Grid View pages, which means that i am loading unnecessary css for some pages that do not use this macro.

    I am mainly looking for advice with this post. Is it an intended feature that we can only add CSS references to Views and not MacroPartials?

    I look forward to hearing your thoughts.

    Thanks Lee

Please Sign in or register to post replies

Write your reply to:

Draft