Hi,
thanks for your question, and sorry for the trouble.
Your best chance is probably to hook into the tablepress_table_render_options plugin filter hook and “abuse” it as an action hook, on which you can then enqueue your script. Something like this for example:
add_filter( 'tablepress_table_render_options', 'lagunas_enqueue_table_script', 10, 2 );
function lagunas_enqueue_table_script( $render_options, $table ) {
// Your enqueue code goes here.
return $render_options;
}
If you explain what kind of script you want to enqueue, I might be able to suggest a better solution.
Regards,
Tobias
Thank you!
The script I’m enqueueing adds the data-heading attribute to table cells:
jQuery('.tablepress').each(function() {
var thetable=jQuery(this);
jQuery(this).find('tbody td').each(function() {
jQuery(this).attr('data-heading',thetable.find('thead th:nth-child('+(jQuery(this).index()+1)+')').text());
});
});
And your solution worked perfectly for what I needed.
Thanks again for your time!!
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
(To make this code faster, you could cache the content of the header cells. From what I can see, you are retrieving that from the DOM for every cell.)
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!