Search code examples
javascriptslidernivo-slider

Nivo Slider have javascript error


I'm building a website which use Nivo Slider. At first, it worked nicely. But yesterday, when I tried again, it's suddenly stop moving. I haven't changed anything yet before I discovered this issue. I looked into the console and there is a javascript error which says:

Uncaught TypeError: Object [object Object] has no method 'live'

When I tried to look into jquery.nivo.slider.js, the error is on $('a.nivo-prevNav', slider) like below:

$('a.nivo-prevNav', slider).live('click', function(){
    // function's content
});

Using google's inspect element feature, I search into the page and found there.

What is wrong with that? why it is suddenly stop moving? Any help would be appreciated.


Solution

  • The Nivo Slider needs jQuery to work. On your website you refer to jQuery like this

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    

    This is pretty dangerous, as the latest version constantly changes. As can be seen from the jQuery documentation at

    http://api.jquery.com/live/

    the live function is deprecated since jQuery 1.7. Looking at the unminified jQuery source at

    http://code.jquery.com/jquery-latest.js

    it seems like the function is not there anymore, which is why you get the error.

    Solution: bind jQuery with a specific version - probably you can find out which version you need from Nivo Slider documentation. Some of the older versions of jQuery can be found here: http://jquery.com/download/