As previously announced via banners and our newsletters, support is no longer available through this platform.

For easier navigation, you can still click on "Submit a Ticket" here, choose the appropriate category, and you'll be redirected to the correct support channel for your plugin.

You can still access your previous tickets and browse public tickets, but please note that responding to tickets is no longer possible.

Paid customers: Please log in to your store account for support.

Pre-purchase questions: Use the support widget in the bottom-right corner of our websites:
https://wpamelia.com
https://wpdatatables.com
https://wpreportbuilder.com

Okay
  Public Ticket #937647
jQuery Selector of wpDatatables
Closed

Comments

  •  2
    lennartwittmann started the conversation

    Hi support team,

    I have got a link column in my table. How can I capture a click on that link by jQuery? 

    I tried several thinks, but even the most general jQuery("a").click gets triggered when clicking any link within the table.

    I even added a class element in the <a> links in class.link.wpdatacolumn.php. So a link would print out <a class="wpdatatable" href="http://www.google,de">Link</a> and removed the target=_blank to remain in the current window.

    But no change either with jQuery(".wpdatatables").

    How can I select links in a wpdatatable by jQuery?

    Thanks a lot!

    Regards, Lennart


  • [deleted] replied

    Hi Lennart,
    Thank you for your purchase.

    If I understand correctly you want to click on a link and get that link with jQuery. E.g. cell data is www.google.com||Google and you want to get just www.google.com?

  •  2
    lennartwittmann replied

    Hi Milos,

    yes I want to process the href value of that link by some external jQuery/AJAX script. In order to do that I need to capture the click on a link within wpdatatables, e. g.

    jQuery('.wpdatatables').click(function(e) { ... // do something });

    But no matter what I define the click event will not get fired. Seems like the click already gets consumed by another script. 

    Question is: which jQuery-selector gets me the click on a link column within wpdatatables?


    BR Lennart


  • [deleted] replied

    Hi Lennart,

    You can use this code as example how to get href attribute from table:

    jQuery(window).load(function() {
        jQuery("#table_1").on('click', 'td > a', function() {
            var link = jQuery(this).attr('href');
            alert(link);
        }).DataTable();
    });
    
  •  2
    lennartwittmann replied

    WOW it worked! Thank your very much, Milos!

    You should published that on your homepage: Accessing table with external jQuery script!

    Thanks (again)!

    Lennart

  • [deleted] replied

    Hi Lennart,

    You are welcome. We'd greatly appreciate it if you could take a minute and leave a review on CodeCanyon on this link. Thanks!