• Hi,
    i wrapped the shrotcode into a button tag because im using the plugin to count a hit on a button…

    <button class="dot-irecommendthis btn btn-default btn-sm" id="dot-irecommendthis-<?php echo $post->ID; ?>" href="#">
     <?php if( function_exists('dot_irecommendthis') ) dot_irecommendthis();?>
    </button>

    it works fine. But when i click on a already clicked button (i using the saved IP) wich has already added the “active” tag – it removes not only the a tag it also removes the spans of the recommend button.

    This is what stays left:

    <button class="dot-irecommendthis btn btn-default btn-sm active" href="#close" title="You already recommended this">1</button>

    Any way to avoid this behavior? Im using a css style after and before each span to display one ICON before the count number and one ICON after the count number – but after the click it removes the spans – and with them the icons…

    This would be awesome if you can tell me wich part of the plugin i should change to achieve my goal.

    Thank you so much for your help

    https://wordpress.org/plugins/i-recommend-this/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Harish Chouhan

    (@hchouhan)

    Hello bffnb,

    I regret to say this is beyond the scope of my free support. I’ll keep this issue open in case someone else has done this and willing to share a solution.

    Hello, you just need to modify the .js that makes the work around with this code:

    $.post(dot_irecommendthis.ajaxurl, { action:’dot-irecommendthis’, recommend_id:id, suffix:suffix }, function(data){
    link.html(“”).addClass(‘active’).attr(‘title’,’You already recommended this’);
    link.append(‘<i class=”fa fa-heart” aria-hidden=”true”></i>’);
    link.append(‘<span class=”dot-irecommendthis-count”>’+data+'</span>’);
    link.append(‘<span class=”dot-irecommendthis-suffix”></span>’);
    });

    what was happening?
    The old code was overwriting the content on the appended link element with the link.html(data), so you just need to clear it at the beggining and generate it again withe the appends I’ve posted

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stop Removing span and styles after click of cliked button’ is closed to new replies.