Copied to clipboard

Flag this post as spam?

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


  • Lars Ljungqvist 5 posts 35 karma points
    Apr 30, 2014 @ 15:58
    Lars Ljungqvist
    0

    MVC template get a file from "script"

    Hi. I am doing a MVC template. I want to include a javascript file, enhanced.js from the "Scripts" directory in the Settings section.

    If it was a Parital View that I wanted to include I would write something like @{ Html.RenderPartial("umbLatestNewsWidget"); }. Does anyone know how to include this enhanced.js file in the template?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 30, 2014 @ 16:39
    Jan Skovgaard
    0

    Hi Lars and welcome to our :)

    You should just reference it in your template before like

    <script src="/scripts/enhanced.js"></script>

    Hope this helps?

    /Jan

  • Lars Ljungqvist 5 posts 35 karma points
    May 01, 2014 @ 08:40
    Lars Ljungqvist
    0

    Hi Jan

    Thank you for your answer and your welcome. I am sorry but I am not sure what you mean. Could you please give me a short code example of how to refer to a file in the directory of "Script" in Razor! I am not even sure what tbe "best practice" is. To make a macro or to refer to the file in the Script directory.

    Thank you in advance
    // Lars

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 01, 2014 @ 10:09
    Jan Skovgaard
    0

    Hi Lars

    Argh, the damn editor did not accept my code from the previous post. Sorry about that. It should read

    <script src="/scripts/enhanced.js"></script>
    

    In regards to the best practice it depends on the site you're building. If you have two sites in the same solutions based on the same document types and templates but with individual functionality then it would be a good idea to use a macro to load stuff like css/scripts so the proper stuff gets loaded accordingly.

    I hope this helps.

    /Jan

  • Lars Ljungqvist 5 posts 35 karma points
    May 01, 2014 @ 13:39
    Lars Ljungqvist
    0

    Hi Jan

    With a small correction using "Scripts" istead of "scripts" meaning that the final code will be: <script src="/Scripts/enhanced.js"></script> it works perfectly fine by now. Thank you very much, Jan, and have a nice day :-)

    // Lars

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 01, 2014 @ 14:58
    Jan Skovgaard
    0

    Hi Lars

    Ah yes well of course! :)

    Happy you managed to solve it though - Remember to mark the post as solved as well.

    A nice day to you as well.

    /Jan

  • Lars Ljungqvist 5 posts 35 karma points
    May 02, 2014 @ 09:21
    Lars Ljungqvist
    0

    Hi Jan. Where do I mark the subject as "solved"?

    // Lars

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 02, 2014 @ 09:58
    Jan Skovgaard
    100

    Hi Lars

    There is a "mark as solution" option in the toolbar where you can edit a post.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft