WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Adding triggers after each ajax call (9 posts)

  1. leoloso
    Member
    Posted 1 year ago #

    Hi Marcus,

    I use jQuery to add css classes to the Events. When there's an ajax call so the content gets refreshed, I need to execute again the jQuery .addClass function.

    I propose that in every ajax function, trigger an event at the end of the success / error function. In my case I added trigger "em_bookings_filtered" like this:

    $(document).delegate('#em-bookings-table form.bookings-filter', 'submit', function(e){
    ...
    $.post( EM.ajaxurl, el.serializeArray(), function(data){

    ...
    $(document).trigger('em_bookings_filtered');
    });
    return false;
    });

    I hope you'll agree :)

    Thanks,
    Leo

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    hi,

    at the moment you can use this jquery hooks - http://wp-events-plugin.com/tutorials/modifying-event-location-google-maps/

    replaced em_maps_location_hook with em_booking_success for booking successful

  3. leoloso
    Member
    Posted 1 year ago #

    but my issue is not about google maps, but for the content brought with ajax after filtering bookings information... and there is no trigger there

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    could you give an example ajax call particularly? we do have some triggers already for bookings and maps for example

  5. leoloso
    Member
    Posted 1 year ago #

    I'm using jQuery to modify the style of table dbem-bookings-table, adding Twitter Bootstrap classes:

    $('#dbem-bookings-table').addClass('table table-bordered table-striped');

    So I must re-execute this jQuery after refreshing the table. Otherwise this new content will have no styles whatsoever.

    So then I have my function:

    jQuery(document).ready(function($){
    $(document).on('em_bookings_filtered', function() {
    $('#dbem-bookings-table').addClass('table table-bordered table-striped');
    });
    });

  6. leoloso
    Member
    Posted 1 year ago #

    Sorry, I'll add some formatting to the code

    jQuery(document).ready(function($){
    	$(document).on('em_bookings_filtered', function() {
    		$('#dbem-bookings-table').addClass('table table-bordered table-striped');
    	});
    });
  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    ok, how about this (last line is new) -

    $('#em-bookings-table-export input[name=scope]').val(root.find('select[name=scope]').val());
    $('#em-bookings-table-export input[name=status]').val(root.find('select[name=status]').val());
    jQuery(document).triggerHandler('em_bookings_filtered', [data, root, el]);
  8. leoloso
    Member
    Posted 1 year ago #

    looks good to me!

    btw, I had problems in that particular jQuery function, but I think there's no harm in implementing this for all functions, somebody else might also need it

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    If there's any others you need, pls let me know and I can add, otherwise will go through the code in detail on a rainy day :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.