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

Forums / General Discussions / Javascript files not being loading in backend

Javascript files not being loading in backend

8 posts, 0 answered
  1. Richard
    Richard avatar
    63 posts
    Registered:
    20 Jan 2010
    30 May 2012
    Link to this post
    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 (http://blog.falafel.com/Blogs/george-saadeh/2012/05/09/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
  2. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    30 May 2012
    Link to this post
    Richard,

    Try this:

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

  3. Richard
    Richard avatar
    63 posts
    Registered:
    20 Jan 2010
    30 May 2012
    Link to this post
    Hi Tim,

    Tried this but it made no difference.

    thanks
  4. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    30 May 2012
    Link to this post
    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! :)

  5. Richard
    Richard avatar
    63 posts
    Registered:
    20 Jan 2010
    30 May 2012
    Link to this post
    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.
  6. Jeremy
    Jeremy avatar
    37 posts
    Registered:
    17 Jan 2011
    14 Jun 2012
    Link to this post
    Richard, did you get this working? I need to implement an image slider and the Nivo Slider looks like a good option.

    Thanks,
    Jeremy
  7. Richard
    Richard avatar
    63 posts
    Registered:
    20 Jan 2010
    14 Jun 2012
    Link to this post
    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
  8. Jeremy
    Jeremy avatar
    37 posts
    Registered:
    17 Jan 2011
    18 Jun 2012
    Link to this post
    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.
8 posts, 0 answered