-
AuthorPosts
-
November 8, 2018 at 4:41 pm #1031311
i tried to get sortable tables with a little plugin
all the plugin needs is a custom class at table tag – and for sorting dates a custom-class at the table heading th.https://webers-testseite.de/sortable-tables/
See here an enfold table with custom-class: sortable ( this is the class needed)
and now the point is that the dates should get a class with date format data string like: dateFormat-ddmmyyyyon that testpage i added Class by th:first-child – but i like to adress it in a common way not by counting.
i tried :
$('th[aria-label*="Datum"]').addClass('dateFormat-ddmmyyyy');
but it does not work this way.
Any suggestion?November 14, 2018 at 10:04 am #1033395Hey Guenter,
The way you are targeting the class using aria-label attribute is correct. I checked your page and it seems like you managed to add custom class – https://prnt.sc/li56sg :)
Best regards,
YigitNovember 14, 2018 at 7:15 pm #1033620yes but i did that by selecting the first-child.
i’d like to select it via the label – if there is Date or Datum (german)so i thought i could do it this way:
$('th[aria-label*="Dat"]').addClass('dateFormat-ddmmyyyy');
but it does not work on jQuery
per css i can select it this way to change color etc.
th[aria-label*="Dat"]
November 19, 2018 at 7:21 pm #1035305Hi,
I tried following code for testing
function testing_to_add_class(){ ?> <script> jQuery(window).load(function(){ jQuery('a.tag-cloud-link[aria-label*="some"]').addClass('testing-to-add-class'); }); </script> <?php } add_action('wp_footer', 'testing_to_add_class');
and it worked on my local installation – https://prnt.sc/lkbzak
Could issue be in your jQuery code?
Best regards,
YigitDecember 3, 2018 at 12:22 pm #1040240sorry for late reply – just worked hard the days before every chistmas time ( customers get buisy in this time)
my code corresponds to the plugin needs – so maybe the shift of containers is responsible for that.
document ready or window load does not do anything on that code – even if i make an own function for that add class rule:function add_thead_tag(){ ?> <script> (function($){ $( '.tablesorter tr.avia-heading-row' ).wrap( '<thead class="sort-able"></thead>' ); $( 'thead.sort-able' ).insertBefore( '.tablesorter tbody' ); $( 'th[aria-label*="Datum"]').addClass('dateFormat-ddmmyyyy' ); })(jQuery); </script> <?php } add_action('wp_footer', 'add_thead_tag');
the first lines are needed to have the needed structure for that little plugin.
on Enfold the table design is like this – and that is normal structure of a table – but that plugin needs the heading in a special container outside the tbody:<table> <tbody> <tr> <td>heading1</td> <td>heading2</td> </tr> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> </tr> </tbody> </table>
PS: it is not so important – i can select it in a different way – but i do not understand why it does not work in this way.
December 4, 2018 at 4:27 pm #1040767Hi,
Not really sure why it is not working. Some other customization might be interfering but the way you target has worked on my end.
If that happens to be the case in future, maybe you could create a testing environment, provide us logins so we can look into it? :)Best regards,
YigitDecember 7, 2018 at 10:03 am #1041959i guess you are right. on my webers-testseite.de there are too many customizations i guess. My child-theme functions.php has over 1500lines –
But on a fresh WP5 / Enfold 4.5.1 this little code does not work as it should too.
https://webers-testseite.de/ostler/first-wp-5-page/Anyway – forget it and close that thing here
Edit : It had to be a combination of shifting the container and after all adding the class – it does not work without window load function but -the shifting a had to be outside that rule:
function fix_for_tablesorter(){ ?> <script> (function($){ $('.tablesorter tr.avia-heading-row').wrap( '<thead class="sort-able"></thead>' ); $('thead.sort-able').insertBefore( '.tablesorter tbody' ); $(window).load(function(){ $('th[aria-label*="Dat"]').addClass('dateFormat-ddmmyyyy'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'fix_for_tablesorter');
- This reply was modified 5 years, 11 months ago by Guenni007.
-
AuthorPosts
- The topic ‘how to address via jquery an element with attribute?’ is closed to new replies.