Skip to content

Instantly share code, notes, and snippets.

@craigsimps craigsimps/global.js
Last active Mar 16, 2018

Embed
What would you like to do?
$(document).on('facetwp-loaded', function () {
/*
* Initialize Soliloquy sliders if they're loaded while filtering.
*
* If a Soliloquy slider is loaded in by Ajax, such is the case
* in the Creative Portfolio section, it won't be initialized. In
* order to do so, we need to call some Ajax of our own and output
* the neccessary JS.
*/
if (FWP.loaded) { // Only after first load.
// Find all sliders with data-soliloquy-loaded=0
var soliloquy_sliders = [];
$(".soliloquy-outer-container[data-soliloquy-loaded='0']").each(function () {
soliloquy_sliders.push($('.soliloquy-container', $(this)).attr('id').replace(/^\D+/g, ''));
});
if (soliloquy_sliders.length > 0) {
// Send list of Soliloquy slider IDs via AJAX call to project_ajax_init_sliders()
$.post(
soliloquy_ajax.ajax,
{
action: 'project_init_soliloquy_sliders',
ajax_nonce: soliloquy_ajax.ajax_nonce,
ids: soliloquy_sliders,
},
function (response) {
if (response !== '-1' && response !== '0') {
eval(response);
}
}
);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.