Copied to clipboard

Flag this post as spam?

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


  • Ambert van Unen 175 posts 819 karma points c-trib
    May 03, 2019 @ 20:54
    Ambert van Unen
    1

    Clientdependency & sections

    I'm experimenting with using Clientdependencies and sections, to only load the required javascript on the templatepage.

    So on the Masterpage I have this:

      @{
            Html.RequiresJs("~/scripts/navigation.js");
            Html.RequiresJs("~/scripts/slick.js");
            @RenderSection("ExtraScripts", false);
            Html.RequiresJs("~/scripts/external/readmore.min.js");
        }  
        @Html.RenderJsHere()
    

    On the templatepage I have this:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using ClientDependency.Core.Mvc;
    @section ExtraScripts
    {
        @Html.RequiresJs("~/scripts/filters.js");
    }
    

    The scripts is being rendered correctly in HTML, but theres a little addition to it.. When I remove the @section, it's gone.. Any idea how to get rid of it ?

      System.Web.Mvc.HtmlHelper`1[Umbraco.Core.Models.PublishedContent.IPublishedContent];
    
    
    <script src="/scripts/navigation.js?cdv=208785142" type="text/javascript"></script>
    <script src="/scripts/slick.js?cdv=208785142" type="text/javascript"></script>
    <script src="/scripts/filters.js?cdv=208785142" type="text/javascript"></script>
    
  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    May 04, 2019 @ 10:19
    Kevin Jump
    0

    Hi

    the thing i do all the time is the put the @ on the front of the Html.Requires when it isn't needed

    so just check - you don't have a @Html.RequiresJs('...') when it should be Html.RequiresJs('...');

  • Ambert van Unen 175 posts 819 karma points c-trib
    May 04, 2019 @ 14:04
    Ambert van Unen
    101

    Thanks for the reply, I've tested this though.

    When I am not using the @ when calling the filters, it only prints the value.

    BUT, when I tried the following. It works, without any extra fluff ;-) Just put them in a code bracket!

    @section ExtraScripts
    {
        @{
            Html.RequiresJs("~/scripts/filters.js");
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft