Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/c678d60c553f5426fe75b25d73683fbd to your computer and use it in GitHub Desktop.
Save Pebblo/c678d60c553f5426fe75b25d73683fbd to your computer and use it in GitHub Desktop.
Example of how to use jQuery to add an 'empty' row when the category you select on Table View Template does not have any events.
<?php // Please do not inlue the opening PHP tag if you alread have one.
function tw_ee_espresso_events_table_template_empty_row() {
wp_add_inline_script(
'espresso_events_table_template',
'jQuery(document).ready(function($){
$("#ee_filter_cat").change(function() {
$(".espresso-table-row.empty").remove();
if( $(".espresso-table-row:visible").length === 0 ) {
var markup =
"<tr class=\"espresso-table-row empty\"><td colspan=\"4\">Sorry, there are no classes scheduled with that parameter. Please contact <a href=\"mailto:Alice@rmf.org\">Alice@rmf.org</a> for more information.</td></tr>";
$("#ee_filter_table tbody").append(markup);
}
})
});'
);
}
add_action( 'wp_enqueue_scripts', 'tw_ee_espresso_events_table_template_empty_row', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment