Skip Navigation

[Resolved] Views Slider with auto Ajax – not allowing Click save jQuery function

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by stuart 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1495611

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've included the logins etc 🙂

#1495679

You also may want to be aware of this ticket I have open that explains a bit about the views in views approach (if this has any relevance).

https://toolset.com/forums/topic/views-slider-with-custom-field-containing-elementor-template-shortcode/

Cheers

#1496159

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me what view you are talking about and what custom JS function you added to it as well as on what page you added your view?

#1500941

My issue is resolved now. Thank you!

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]
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.