Javascript error

Posted by Community Admin on 03-Aug-2018 14:44

Javascript error

All Replies

Posted by Community Admin on 09-Feb-2011 00:00

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

Posted by Community Admin on 09-Feb-2011 00:00

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

Posted by Community Admin on 09-Feb-2011 00:00

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

Posted by Community Admin on 15-Feb-2011 00:00

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

Posted by Community Admin on 11-Mar-2011 00:00

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

This thread is closed