+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / @Html.Script(ScriptRef.JQuery, "top")

@Html.Script(ScriptRef.JQuery, "top")

5 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    04 Jun 2015
    Link to this post

    Can someone please tell me how this all works?

     Lets say in my layout I have 

    @Html.Script(ScriptRef.JQuery, "bottom")

    But every widget has

    @Html.Script(ScriptRef.JQuery, "top")

    ...am I getting 2 jQuery instances loaded...or can it be defaulted to bottom, or does top override it...???

  2. Christian
    Christian avatar
    23 posts
    Registered:
    31 Jul 2008
    07 Jun 2015 in reply to Steve
    Link to this post
    An answer to this would be great!
  3. RJ Cuthbertson
    RJ Cuthbertson avatar
    41 posts
    Registered:
    01 Jun 2015
    08 Jun 2015
    Link to this post

    You can test this out by adding multiple references to the same script on a page and watching the ​generated HTML.

     

    The script will only be added to the page once, not once in each section. The section that it renders in appears to always be the first section in the document that it was added to. For example, if you added jQuery to "top" and "bottom" it will add the script tag to the "top" section and will not duplicate it further down the page where the "bottom" section is.

  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    08 Jun 2015 in reply to RJ Cuthbertson
    Link to this post

    Yeah it's only once, but it seems that it should send it to whichever comes first, which is just what I'd like clarified...

    https://github.com/Sitefinity/feather/blob/b20884d1f73c140befeeaee4d9022d07a8cbe17a/Telerik.Sitefinity.Frontend/Resources/ResourceRegister.cs

     Looks like once it registers in a section, all other sections are ignored.​  So if "bottom" came first somewhere, then it becomes bottom globally.

  5. RJ Cuthbertson
    RJ Cuthbertson avatar
    41 posts
    Registered:
    01 Jun 2015
    08 Jun 2015
    Link to this post

    It puts the script block in the section declared first in the page markup. It doesn't matter which order you place the script references themselves in. What I mean by this is that

     

    @Html.Script(ScriptRef.JQuery, "top")

    @Html.Script(ScriptRef.JQuery, "bottom")

     - AND -

    @Html.Script(ScriptRef.JQuery, "​bottom")
    @Html.Script(ScriptRef.JQuery, "top")

     

    both produce the same result. The script reference is included in the "top" section, since it is the first section declared in the page.

5 posts, 0 answered