Skip to content

Instantly share code, notes, and snippets.

@craigsimps
Last active March 16, 2018 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigsimps/904b7b0db76fe410058d75012470df77 to your computer and use it in GitHub Desktop.
Save craigsimps/904b7b0db76fe410058d75012470df77 to your computer and use it in GitHub Desktop.
$(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