I am working on a site that relies heavily on AJAX while switching between pages. It is a WordPress site using the RoyalSlider image slideshow plugin. You create slideshows through the plugin, then you add the relevant shortcode in the post. The shortcode will automatically generate the jQuery that initializes the slider, but it binds it to the document-ready event, which doesn't fire when a new page loads via ajax. I know where to initialize the slider within my AJAX call, except this will not let me load the slider options defined in the plugin.
The correct jQuery code (including the options) does get created in the HTML.
<script id="new-royalslider-init-code" type="text/javascript">
...
</script>
How can I extract this jQuery code, and initialize the slider manually using the code in this script tag?
I know that I can grab the code like this:
$('#new-royalslider-init-code').html()
But I don't know how I could execute it. Here is a sample of the script tag:
<script id="new-royalslider-init-code" type="text/javascript">
jQuery(document).ready(function($) {
$('.new-royalslider-2').royalSlider({...OPTIONS...});
});
</script>
Any help would be appreciated. Thanks!
Try this:
var a = 'alert(1)';
eval(a);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With