Last active
March 16, 2018 14:01
-
-
Save craigsimps/904b7b0db76fe410058d75012470df77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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