I wrote a
WordPress plugin that uses the Mike Alsup's Cycle plugin for jQuery to build an image slideshow. I've got the basic options down pat, but I wanted to get more advanced and I'm stuck. My problem is that I need to pass options dynamically to Cycle depending on the plugin configuration - which can change multiple times per page. An obvious example is adding a play button: I would like to initialize a particular instance of Cycle with a timeout of 0, but if someone hits the play button, I'd like to restart the slideshow with the same options, with a new timeout, starting from the current slide.
Another example is pagers: some slideshows have a pageAnchorBuilder, some do not. So I would want to be able to include that option for a particular slideshow only if I need it.
Maybe this is something specific to Cycle, or maybe it's just some general jQuery knowledge that I don't have yet, but is it possible to update the options for a particular Cycle instance without specifying all of the options again?
A very basic code example:
My original Cycle instance with a timeout of zero:
$('#slideshow1').cycle({
fx: fade,
speed: 400,
timeout: 0,
next: '.next',
prev: '.prev'
});
When someone hits the play button, I would like to reinitialize the Cycle with a new timeout option, without specifying all of the other options again.
Something like this:
$('#play1').click(function() {
$('#slideshow1').cycle({timeout:3000});
});
Where it inherits the options from the previously existing slideshow, but overwrites the timeout value. Is this possible?
Many thanks,
Dalton