3
votes

Is there a way, in jQuery Cycle, to retrieve a parameter?

Example

$('#slider').cycle({speed: 750})

How can I, in Javascript/jQuery, retreive the value 750?

I tried
console.log( $('#slider').cycle.speed )
console.log( $('#slider').cycle.('speed') )

but the value is undefined

3

3 Answers

5
votes

I don't see any plugin commands which allow you to retrieve the value. However, exploring the results with Firebug, it appears that the plugin stores its options under the cycle.opts data attribute. If you really need to get at the value, you can use:

$('#pics').data("cycle.opts").speed

Demo: http://jsfiddle.net/ZWDa4/

Note that this is not an ideal solution since there's no guarantee that it will continue to work with future updates.

1
votes

Should it not be:

console.log($("#slider").cycle("speed"));

Or

var s = $("#slider").cycle();
console.log(s.speed);

Not having it to test means I can't be 100% sure, but all the options are here (as you probably know) http://jquery.malsup.com/cycle/options.html

The final option is to change the approach:

var speed = 750
$("#slider").cycle({"speed: " + speed });

Then you have the speed as a seperate variable?

0
votes

You can try with jquery.data(element,key,value) . Eg: jquery.data($('#slider'),cycle,speed)