Geraldo Isaaks Geraldo Isaaks - 11 months ago 67
jQuery Question

Store and retrieve chained jquery effects/objects in variable

I want to dynamically change jquery effects by storing the chained objects in a variable and concatenating to selector later, so that i have the latest required effect when it needs to exec.
i store a predifined set of jquery chained effects - fadeOut().end().next().fadeIn() - in the data-effect attr, which can change, so i need to reference back to it via a variable to add the effects to $(contentDiv) selector.
So something like; $(selector)effect, won't work.

var effects = document.getElementById('effect').getAtttribute('data-effect');


How about this (updated):

var effect = "";
var $obj = $(contentsDiv);
    function(key, value) {
        $obj = $obj[value]();