[Social Warfare Plugin] Custom click event on share buttons not working

Dear Support team
I am working with the Social Warfare Plugin (https://warfareplugins.com/products/social-warfare/) on several of my websites and I have the same problem everywhere: I am trying to add a custom jQuery click event to the Share Buttons, which are added to the page via shortcode. In this case the click event should show a hidden div element on the page.

As far as I can see, the newly added click event does not fire. I think it's not firing, because the Script of the social warfare plugin binds an .off-click event to the button, which fires everytime the button is clicked (button class; „.nc_tweet“). Here’s the script from Social Warfare: http://uncode.jniederh.ch/wp-content/plugins/social-warfare/assets/js/script.min.js?ver=3.3.3

My custom click event, that I want to add, does work on any other element except the share buttons:

jQuery(document).ready(function(){
jQuery(".nc_tweet":wink:.click(function () {
jQuery(".after-share":wink:.show("slow":wink:;
});
});

Is there any way, to get my custom click event to fire? Maybe you could provide a hint, how I could get this to work?
Many Thanks in advance!

  • Adam Czajczyk
    • Support Gorilla

    Hi Johannes

    I checked the code that you shared (see below) on the site assigned to this ticket by adding it via browser (Chrome) console directly and it seemed to work fine.

    When I clicked on the "twitter" button, it opened a popup and revealed a "Grossartig! Wenn du wissen willst, wie es weitergeht, gib hier einfach deine Adresse ein." message below buttons.

    The code I used was:

    jQuery(document).ready(function(){
    	jQuery(".nc_tweet").click(function () {
    		jQuery(".after-share").show("slow");
    	});
    });

    That would mean that the code itself is working. Can you tell me please how/where exactly are you adding that code to the site?

    Best regards,
    Adam

  • Johannes
    • New Recruit

    Hi Adam,

    Thanks for the reply, we have found a solution to get it working by not using jQuery to select the element but plain Javascript using the the following Code:

    document.querySelector('.nc_tweet ').addEventListener('click',function(){
    $( ".after-share" ).show( "slow", function() {
              });
    });

    Best regards,
    Johannes

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.