Recently I worked on a site which had sliders running through the Aviapoly Slider jQuery plugin. However, it had a certain problem that the sliders stopped working after sliding into the 2nd slide. That is, if you click next or on the numbered dots to go to a particular slide, it will work for the first time, but will stop working after that. So doesn’t matter whether the slider is in auto rotation or you manually click the next and previous button to slide the images, it will not work after working once. There were no critical errors due to bad syntax or something like that, so I had to go through all of the code to find the bug. It was very time consuming, so let me share with you what fixed the problem for me so that you may find it useful.

Cause of the Problem

The problem was occurring because a critical function that changed the slides was not getting called. The following code around line #1035 in the plugin should  call the change_finished function but apparently it was failing to do so.

The plugin has a custom animate function which goes like below:

In the above code, the problem is, if slider.css_active is true, then the callback function will only get called if the callback_delay parameter is also passed. Otherwise it will not call the callback function. And in the methods.animate(….) function mentioned above there was no callback_time value being passed. So the change_finished method was not getting called and the slider stopped working. Once this bug had been identified, the solution was easy.


To fix this, we can either pass in a 4th argument as the callback_time or we can make change to the animate method so that it calls the callback function even when a callback_time is not specified. This second solution is better as it will fix the bug present in the code. So to solve the issue, just change the animate method to something like below:

What we did is, just added extra conditions to check for presence of a callback function and call it even if no callback_time is specified. This fixed the problem for me. If you are facing similar problem, see if this is the issue.