Support » Plugin: Events Manager » Adding triggers after each ajax call

  • Resolved leoloso

    (@leoloso)


    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/

Viewing 8 replies - 1 through 8 (of 8 total)
  • 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

    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

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

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

    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’);
    });
    });

    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');
    	});
    });
    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    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]);

    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

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    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 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding triggers after each ajax call’ is closed to new replies.