Javascript files not being loading in backend

Posted by Community Admin on 03-Aug-2018 11:56

Javascript files not being loading in backend

All Replies

Posted by Community Admin on 30-May-2012 00:00

Hi,

We are creating a new website in the latest version (v5.02860) of Sitefinity and have implemented the NivoSlider. This works fine until we log into the backend and go to the homepage where the slider is and we get the error "Error: Object doesn't support this property or method". After investigating the jquery.nivo.slider.pack.js include is never loaed on the page on the admin backend hence the nivoslider function on the masterpage causes the error.

This previously worked fine in Sitefinity 4.4 so something seems to have changed somewhere.

Just to give a snippet of how this originally worked in Sitefinity 4.4:

<sf:ResourceLinks ID="resourcesLinks" runat="server">
        <sf:ResourceFile JavaScriptLibrary="JQuery" />
    </sf:ResourceLinks>
    <script src="/js/jquery.nivo.slider.pack.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(window).load(function ()
            $('#slider').nivoSlider(
                effect: 'slideInLeft',
                pauseTime: 8000
            );
        );
    </script>

After searching through the forums I read a post where someone recommends using

<sf:JavaScriptEmbedControl ID="script1" runat="server" ScriptEmbedPosition="InPlace" Url="~/NivoSlider/jquery.nivo.slider.pack.js" />

I have tried this but still get the same error and also tried changing the ScriptEmbedPosition to BeforeBodyEndTag but still no luck.

The only way I can get around the error is by loading the scripts in the PreRender of the masterpage as per this post by Falafel (blog.falafel.com/.../using-jquery-and-other-javascript-libraries-in-sitefinity) although when you view the page in the backend the slider doesn't show at all but at least there is no error.

Has anyone else came across this and have been able to resolve?

Thanks
Richard

Posted by Community Admin on 30-May-2012 00:00

Richard,

Try this:

<script type="text/javascript">
    jQuery(window).load(function ()
        jQuery('#slider').nivoSlider(
            effect: 'slideInLeft',
            pauseTime: 8000
        );
    );
</script>

Posted by Community Admin on 30-May-2012 00:00

Hi Tim,

Tried this but it made no difference.

thanks

Posted by Community Admin on 30-May-2012 00:00

Well, that's disappointing.

Are you familiar with jQuery conflicts? That may be what's going on but I'm not sure. I load jQuery in through the master page using Google CDN. Sometimes, I get conflicts...especially when using certain controls. In those instances, I have to make sure that I $.noConflict() to get access to scripts that were loaded in prior.

Hopefully that works out! :)


Posted by Community Admin on 30-May-2012 00:00

Thanks,

I don't think that there are any conflicts as the JQuery library is loading but not the jquery.nivo.slider.pack.js in the admin mode.

Posted by Community Admin on 14-Jun-2012 00:00

Richard, did you get this working? I need to implement an image slider and the Nivo Slider looks like a good option.

Thanks,
Jeremy

Posted by Community Admin on 14-Jun-2012 00:00

Hi Jeremy,
I didn't, I followed the Falafel link in my first post although when on the page in the admin backend the slider doesnt show which isn't a huge deal and it's better than having errors.

thanks

Posted by Community Admin on 18-Jun-2012 00:00

Richard, thanks for replying. I ended up implementing the WOW Slider in a widget control. It was quite easy, although I admit I'm using several static images so it's not wired into the Sitefinity galleries. I imagine it wouldn't be too difficult to add that functionality. 

http://wowslider.com/ 

I simply created a widget using Sitefinity Thunder. I put the HTML in the widget and then dropped CSS & Script widgets on my site template to load the CSS and script files.

This thread is closed