Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:18:26+00:00 2026-06-08T03:18:26+00:00

I am ajaxing in new buttons after each successful http request. //Remove events and

  • 0

I am ajaxing in new buttons after each successful http request.

//Remove events and items
$('#sthoverbuttons-chicklets span').remove();

I then add new items with new events in by passing an object into stwidget.

See here documentation for sharethis: http://support.sharethis.com/customer/portal/articles/475079-share-properties-and-sharing-custom-information#Dynamic_Specification_through_JavaScript

//Finish with share buttons
wyrAjax.sharethis.finishAddingShareButton();

wyrAjax.sharethis = {
//Grab the current share height so we can keep it this height when we remove all the items
    shareThisHeight:null,
    init:function () {

        //If the height has not been set set it
        if(wyrAjax.sharethis.shareThisHeight===null){
            wyrAjax.sharethis.shareThisHeight = $('#sthoverbuttons').outerHeight();
        }

        //Set up elements so that we can use them as ID's
        $('.sthoverbuttons-chicklets').attr('id', 'sthoverbuttons-chicklets');
        if (!$('#shareLoading').length) {
            $('#sthoverbuttonsMain').append('<div id="shareLoading"><img src="/img/loading.gif" style="position: absolute; top: 50%;left: 37%"></div>');
        }
    },
    shareTypes:function(){
        var array = [];
        array[0]={
            "service":"facebook"
        };
        array[1]={
            "service":"twitter"
        };
        array[2]={
            "service":"delicious"
        };
        array[3]={
            "service":"googleplus"
        };
        array[4]={
            "service":"reddit"
        };
        array[5]={
            "service":"tumblr"
        };
        array[6]={
            "service":"stumbleupon"
        };
        array[7]={
            "service":"digg"
        };
        array[8]={
            "service":"sharethis"
        };
        return array;
    },
    startGettingShareButton:function () {
        //First we run a quick check to see if the elemnts have ID's
        wyrAjax.sharethis.init();

        //Now lets fade out and clean up all the shares so we can add new shares in.
        $('#sthoverbuttons-chicklets').hide();

        $('#sthoverbuttonsMain').height(wyrAjax.sharethis.shareThisHeight);
        wyrAjax.sharethis.addLoadingToShare();
    },
    addLoadingToShare:function () {
        $('#shareLoading').show();
        $('#sthoverbuttons-chicklets span').off().remove();
    },
    finishAddingShareButton:function () {
        $('#shareLoading').hide();
        var shareItems = wyrAjax.sharethis.shareTypes();
        $.each(shareItems,function(key, value){
            wyrAjax.sharethis.addShareThisButton(value);
        });
        $('.sthoverbuttons-chicklets').show();
    },
    addShareThisButton:function (object) {
        stWidget.addEntry({
            "service":object.service,
            "element":document.getElementById('sthoverbuttons-chicklets'),
            "url":"http://www.wouldyourathers.co.uk/question/" + wyrAjax.questionDetails.id,
            "title":"Would You Rather | " + wyrAjax.questionDetails.q1,
            "type":"large",
            "text":"Would You Rather " + wyrAjax.questionDetails.q1 + " or " + wyrAjax.questionDetails.q2,
            "summary":wyrAjax.questionDetails.q1 + " or " + wyrAjax.questionDetails.q2
        });
    }
};

When I click one of the newly added buttons it will go to for example the share feature of twitter, but it will also bring up for some reason Facebook’s share.

I believe I want to remove all events on the spans before I re-add them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:18:27+00:00Added an answer on June 8, 2026 at 3:18 am

    So the problem i was having is that sharethis doesn’t want you remove the share items. Sharethis stWidget.addEntry doesn’t want to you to add new dom items, it wants you to replace the current share butons already on the page.

    With this in mind i edited my code to add ID’s to all buttons already shared:

     //Give all share buttons ID's
     var shareItems = wyrAjax.sharethis.shareTypes();
     $.each(shareItems,function(key, value){
       $('.st_'+value.service+'_large').attr('id','st_'+value.service+'_large');
     });
    

    Then i used Sharethis’s addEntry to just replace the existing button.

    wyrAjax.sharethis = {
        //Grab the current share height so we can keep it this height when we remove all the items
        shareThisHeight:null,
        init:function () {
    
            //If the height has not been set set it
            if(wyrAjax.sharethis.shareThisHeight===null){
                wyrAjax.sharethis.shareThisHeight = $('#sthoverbuttons').outerHeight();
            }
    
            //Set up elements so that we can use them as ID's
            $('.sthoverbuttons-chicklets').attr('id', 'sthoverbuttons-chicklets');
            if (!$('#shareLoading').length) {
    
                //Give all share buttons ID's
                var shareItems = wyrAjax.sharethis.shareTypes();
                $.each(shareItems,function(key, value){
                    $('.st_'+value.service+'_large').attr('id','st_'+value.service+'_large');
                });
    
                $('#sthoverbuttonsMain').append('<div id="shareLoading"><img src="/img/loading.gif" style="position: absolute; top: 50%;left: 37%"></div>');
            }
        },
        shareTypes:function(){
            var array = [];
            array[0]={
                "service":"facebook"
            };
            array[1]={
                "service":"twitter"
            };
            array[2]={
                "service":"delicious"
            };
            array[3]={
                "service":"googleplus"
            };
            array[4]={
                "service":"reddit"
            };
            array[5]={
                "service":"tumblr"
            };
            array[6]={
                "service":"stumbleupon"
            };
            array[7]={
                "service":"digg"
            };
            array[8]={
                "service":"sharethis"
            };
            return array;
        },
        startGettingShareButton:function () {
            //First we run a quick check to see if the elemnts have ID's
            wyrAjax.sharethis.init();
    
            //Now lets fade out and clean up all the shares so we can add new shares in.
            $('#sthoverbuttons-chicklets').hide();
    
            $('#sthoverbuttonsMain').height(wyrAjax.sharethis.shareThisHeight);
            wyrAjax.sharethis.addLoadingToShare();
        },
        addLoadingToShare:function () {
            $('#shareLoading').show();
        },
        finishAddingShareButton:function () {
            //Remove the loading.gif
            $('#shareLoading').hide();
    
            //grab array of different share types
            var shareItems = wyrAjax.sharethis.shareTypes();
    
            //Loop through 
            $.each(shareItems,function(key, value){
                wyrAjax.sharethis.addShareThisButton(value);
                $('#st_'+value.service+'_large > span:first-child').remove();
            });
            $('.sthoverbuttons-chicklets').show();
        },
        addShareThisButton:function (object) {
            stWidget.addEntry({
                "service":object.service,
                "element":document.getElementById('st_'+object.service+'_large'),
                "url":"http://www.wouldyourathers.co.uk/question/" + wyrAjax.questionDetails.id,
                "title":"Would You Rather | " + wyrAjax.questionDetails.q1,
                "type":"large",
                "text":"Would You Rather " + wyrAjax.questionDetails.q1 + " or " + wyrAjax.questionDetails.q2,
                "summary":wyrAjax.questionDetails.q1 + " or " + wyrAjax.questionDetails.q2
            });
        }
    };
    

    Hopefully somebody can find this helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm ajaxing an array of images from a file with php opendir function .
I'm ajaxing my content and can't figure out why i can't pass a variable
I have some Ajaxing going on and I have 2 blocks of source code.
I have the following function which is for ajaxing in a page and the
I see thousands of posts that have to do with ajaxing wordpress but none
I have a gallery of images that I'm ajaxing in and I'd like to
I am ajaxing in some text from a PHP script and trying to have
I'm ajaxing some search results onto a page, and trying to do stuff when
I am trying to AJAX a request to 192.158.110.129:5000 (Flask Webserver), while the whole
I am ajaxing a page and on success I have following code: success: function(html){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.