Hi again, I have a slider that is using "Pagination enabled with automatic AJAX transition"
- on the slider, there is a button that fires an onclick event to a custom function to update a custom meta field on the custom post in the loop... this doesnt work with Ajax transition is on, but does when it is not turned on.
I assume this is to do with setting up a "Callback function" - but for the life of me can't get it to work.
The end game here is to set a custom field value of "1" when the very first instance of the custom post being shown in the slider (page load with this Post ID) happens - this will trigger a sound into the office (introducing a new sale), but only once (I'll hook this up with a conditional for future rotations of the slide if = "1" don't play the sound).
Custom Code in Toolsets: update-audio-play
based on this: hidden link
This works ok on click, just not when ajax transition is turned on.
I figured out what I needed to do... for anyone else:
I added the script tags in the view loop item, when the slider moved to the next item the custom JS was run and a number assigned to the just viewed slide.
(The custom Javascript function I was ruining was in the link above.).
The idea here was when a custom post type was new it would run a sound 'once' on the first slider, then on subsequent sliders it would not make a sound - and it works.
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<!-- Dont forget to add your content, fields etc I removed mine to save confusion -->
<script>
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
/** alert("Hello! I am an alert box!"); **/
jQuery(document).ready( function($) {
var post_id = [wpv-post-id];
$.ajax({
type: 'POST',
url: ajax_object.ajaxurl,
data: {
action: 'custom_update_post',
post_id: post_id
}
});
});
});
</script>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No Leads Found!!![/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]