Vimpil Vimpil - 3 months ago 8
Javascript Question

How to put jQuery "fancybox" plugin values in array\variable and use it later using javascript?

I have multiple fancyboxes in my code and want to minimize options inside the fancybox to use whole block of options like a variable or an array to make code look nice and call options by one string of code. How can i do it with javascript?

$(".present_window").fancybox({


"wrapCSS": "call",
"padding": 0,
helpers: {
overlay: {
locked: false,
opacity: 0.1,
css: {
'background': 'rgba(90, 92, 94, 0.8)'
}
}
}

})

Answer

May be that's what are you looking for https://jsfiddle.net/hrw1c2b4/

var optionCoffee = {
    wrapCSS: "call",
    padding: 0,
    helpers: {
        overlay: {
            locked: false,
            opacity: 0.1,
            css: {
                'background': 'rgba(90, 92, 94, 0.8)'
            }
        }
    }
};

$(".present_window").fancybox(optionCoffee);
Comments