I am using the Nivo Slider plugin for jQuery. The plugin allows you to provide some callbacks in an object inside the parameters of the plugin’s prototype e.g.
$('.slider').nivoSlider({
afterLoad: control_responses(this, false),
beforeChange: control_responses(this, false),
afterChange: control_responses(this, false)
});
Where I have passed this to control_responses() I actually want to send the current iteration of $('.slider') however this currently refers to the window object.
How would I pass the current iteration of $('.slider') to my callback functions?
You are calling the
control_responsesfunction and putting the return values in the object. Put functions in the object so that thecontrol_responsesfunction will be called when the callback function is called: