jQuery in Master pages

Posted by Community Admin on 04-Aug-2018 16:05

jQuery in Master pages

All Replies

Posted by Community Admin on 06-Jun-2011 00:00

Hi All,

I have a news ticker in a static template using jQuery and the newsTicker library, which works perfectly. However, when I attempt to do the same in the .Master template for my Sitefinity project I get an error (Microsoft JScript runtime error: Object doesn't support property or method 'newsTicker').

On tracing this using firebug, it seems to be due to a conflict as there are two versions of jQuery loading (1.6.1 and 1.5.2). I am including version 1.6.1 myself in the header, but Sitefinity is automatically including 1.5.2.

However, if I remove my reference to jQuery, it fails as jQuery.newsTicker.js loads BEFORE Sitefinity's call to load the jQuery library.

My head section looks like this:

<head runat="server">
    <title></title>
 
    <script type="text/javascript" language="javascript" src="/script/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" language="javascript" src="/script/jquery.newsTicker.js"></script>
    <script type="text/javascript" language="javascript">
    //<![CDATA[
        $(document).ready(function ()
            $(".main-left-navigation .selected li").detach().appendTo(".minor-left-navigation");
            $(".main-left-navigation .selected ul").remove();
             
            if ($("#news-ticker").length != 0)
                var options =
                    newsList: "#news-ticker",
                    startDelay: 10,
                    placeHolder1: "_",
                    controls: false,
                    resumeOffHover: true
                
                $().newsTicker(options);
            
 
            $(".search-query").focus();
        );
    //]]>
    </script>
</head>

So my question would be EITHER:

1) Can I prevent Sitefinity automatically adding jquery 1.5.2?
2) Can I force jquery.newsTicker.js to load AFTER the Sitefinity copy of jQuery?

Any help would be appreciated!

Thanks,
Paul

Posted by Community Admin on 07-Jun-2011 00:00

I've put the document.ready calls in a new file called document.ready.js and moved both scripts to the <scriptmanager> but Sitefinity still adds its calls to load jQuery AFTER mine! :-/

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="/script/jquery.newsTicker.js" />
        <asp:ScriptReference Path="/script/document.ready.js" />
    </Scripts>
</asp:ScriptManager>

Grrrr!

Paul

Posted by Community Admin on 07-Jun-2011 00:00

Hello Paul,

Please make sure that you either register the script as a resource or you include it before the closing </form> tag. Also in order to have jQuery included in your page use this code

<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>

<sf:ResourceLinks id="resourcesLinks" runat="server">
<sf:ResourceFile JavaScriptLibrary="JQuery" />
</sf:ResourceLinks>


Sitefinity uses jQuery version  1.5.2. You can also add scripts by using the built-in javascript widget.

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 07-Jun-2011 00:00

Hi Ivan.

Thanks. Moving the script tag to just before the </form> works, however not having them in the <head> seems a bit odd (and really quite ugly!).

Is there a way to upgrade the version of jQuery to use 1.6.1 rather than 1.5.2?

Paul

Posted by Community Admin on 07-Jun-2011 00:00

Hello Paul,

You can change it from the configurations - Administration >> Settings >> Pages, but this could breaks some of the built-in functionality. We haven't tested with 1.6 and I suggest that you should keep using 1.5.2

Kind regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 07-Jun-2011 00:00

Thanks Ivan.

You mentioned a built-in javascript widget? Can you point me in the right direction for the documentation?

Paul

Posted by Community Admin on 30-Jun-2011 00:00

I understand that 1.5.2 is the built-in, but without 1.6, we cannot go to JQuery Mobile 1 BETA from ALPHA.

Do we expect 1.6 to be supported in SF4?

Posted by Community Admin on 30-Jun-2011 00:00

Hello Daniel,

We update the scripts regularly, so there will be update of jQuery for sure. This task has not been scheduled yet, since we work on bug fixes now and new implementation that will be available for Q2. 

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed