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

Forums / General Discussions / Javascript error

Javascript error

5 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    09 Feb 2011
    Link to this post
    Hi,

    I've converted a normal ASP.NET website to SF4.0. 
    One masterpage and one normal page.

    On this masterpage I included two links:
    1. Link to Jquery library
    2. Link to custom jquery functions (main.js) (slider functionality)

    In the normal website, all is rendered as expected and all is working okay.

    When converting all to SF4.0 I'm getting an error inside my main.js file that the object doesn't exists?
    I cannot figure out why this is happening. All code is exactly the same.

    I did the same thing in SF3.7 and there it wokrs okay?
    So, a little confused...

    Any idea's?

    Regards,
    Daniel
  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    09 Feb 2011
    Link to this post
    When using the <sf:JavascriptEmbedControl /> the script is rendered in the <head> section like this:
    <script type="text/javascript" src="~/Assets/js/jquery.main.js"></script>

    That doesn't seem right to me? I don't expect this '~' up there...

    Regards,
    Daniel
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    09 Feb 2011
    Link to this post
    Okay, so I got it working by doing this:
    <sf:JavaScriptEmbedControl ID="jquery" runat="server" ScriptEmbedPosition="BeforeBodyEndTag"
            Url="Assets/js/jquery.main.js">
        </sf:JavaScriptEmbedControl>

    Including my custom jquery code inside the header gives all kind of errors. Now I don't load a jquery library and only my custom jquery code before the body end tag. Now all runs okay. 

    1. What version of jquery is Sitefinity using? Is it loaded by default?
    2. What to do about the not working '~' ? Or am I wrong about this?

    Regards,
    Daniel
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Feb 2011
    Link to this post
    Hello Daniel,

    Thank you for using our services.

    The problem with using application relative path in the Url has been logged as bug (#107996). For now you should use rooted path (starting with "/" from the website root) or use full Url starting with "http://".

    Unfortunately this control does not allow to link the JavaScript libraries which ship with Sitefinity. I have logged a product backlog item (#108035) to extend the control to allow for selection of a number of JS libraries.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Michael
    Michael avatar
    18 posts
    Registered:
    26 Jan 2011
    11 Mar 2011
    Link to this post
    Thanks Daniel,

    I've been dealing with odd javascript errors saying things like my function is not defined. I was using the Javascript widget and telling it to put my js reference in the Head but I could never get my js to work. Your suggestion to place the reference before the Body end tag did the trick.

    Michael
5 posts, 0 answered