-1

I am implementing a share function in my javascript. but the button link doesn’t appear, I’m really a beginner and researched but I couldn’t find out where I’m wrong, the button link just doesn’t appear, there’s no error log on my console. I am really lost if someone can help me I am grateful.

Before opening this question, I saw all the questions related to the same problem, but none were successful in my case.

$(document).ready(function() {

function sharefbimage() {
    FB.init({ appId: `XXXXXX`, status: true, cookie: true });
    FB.ui(
    {
        method: `share`,
        name: 'Facebook Dialogs',
        href: $(location).attr('href'),
        link: 'https://developers.facebook.com/docs/dialogs/',
        picture: 'your image url',
        caption: 'Ishelf Book',
        description: 'your description'
    },
    function (response) {
        if (response && response.post_id) {
            alert('success');
        } else {
            alert('error');
        }
    }
)};
    $(".result").on("click", function() {
        
        var id = $(this).attr("data-linkId");
        var url = $(this).attr("href");

        if(!id) {
            alert("data-linkId attribute not found");
        }

        increaseLinkClicks(id, url);

        return false;
    });


    var grid = $(".imageResults");

    grid.on("layoutComplete", function() {
        $(".gridItem img").css("visibility", "visible");
    });

    grid.masonry({
        itemSelector: ".gridItem",
        columnWidth: 200,
        gutter: 5,
        isInitLayout: false
    });


    $("[data-fancybox]").fancybox({

        caption : function( instance, item ) {
            var caption = $(this).data('caption') || '';
            var siteUrl = $(this).data('siteurl') || '';
            var sharefbimage = $(this).data('siteurl') || '';

            if ( item.type === 'image' ) {
                caption = (caption.length ? caption + '<br />' : '')
                 + '<a href="' + item.src + '">View image</a><br>'
                 + '<a href="' + siteUrl + '">Visit page</a>';
                 + '<a href="' + sharefbimage + '">share</a>';
            }

            return caption;
        },
        afterShow : function( instance, item ) {
            increaseImageClicks(item.src);
        }


    });
3
  • View Image and Visit page are showing. So what the problem? Commented May 1, 2021 at 23:44
  • Thanks for your reply . view image and display of the visit page are being displayed. Just share link does not appear
    – Davi
    Commented May 1, 2021 at 23:52
  • Share link should display like the other two links. If not, I would doubt the styles of it. Just check if the element is in the DOM tree Commented May 2, 2021 at 0:06

1 Answer 1

1

Try this.

  if ( item.type === 'image' ) {
                caption = (caption.length ? caption + '<br />' : '')
                 + '<a href="' + item.src + '">View image</a><br>'
                 + '<a href="' + siteUrl + '">Visit page</a><br>'
                 + '<a href="' + sharefbimage + '">Share</a>';
            }
2
  • Sorry for my irrelevant question
    – Davi
    Commented May 2, 2021 at 1:53
  • No problem, relax ;)
    – user12000870
    Commented May 2, 2021 at 20:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.