添加这在ajax加载后无法正常工作 [英] AddThis not working after ajax load

查看:111
本文介绍了添加这在ajax加载后无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有AddThis js用于将详细信息加入日历。这在页面加载时正常工作,但是我使用ajax加载进行了一些过滤并替换了html,之后AddThis按钮没有显示。这是我的代码ajax。

I have the AddThis js for bookmarking the details to the calender.This is working correctly on page load,but I do some filtering using ajax load and replace the html, after this the AddThis button not showing.here is my code for ajax .

$('document').ready(function () {

    $('.eventSelect').change(function () {
       var selectedDate = $('#eventDate').val();
        var keyword = $('#eventsearch').val();
        var url = "/EventsHome?eventDate=" + selectedDate + "&keyword=" + keyword;
       $.ajax({
           type: "GET"
          , url: url
          , success: function (data) {
              console.log($(data).find(".eventList").html());
              $(".eventList").html($(data).find(".eventList").html());
             var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
                  if (window.addthis) {
                      window.addthis = null;
                      window._adr = null;
                      window._atc = null;
                      window._atd = null;
                      window._ate = null;
                      window._atr = null;
                      window._atw = null;
                  }
                  $.getScript(script);

             }
          , error: function (XMLHttpRequest, textStatus, errorThrown) {

          }, comeplete: 


推荐答案

加载新内容时使用此脚本:

Use this script when you load new content:

if(typeof addthis !== 'undefined') { addthis.layers.refresh(); }

这只是 addthis_inline_share_toolbox 的解决方案!

addthis.toolbox()仅在你在addthis元素中指定了按钮时才有效(大部分是旧版本)。

addthis.toolbox() works only when you have specified buttons inside addthis element (mostly older versions).

这篇关于添加这在ajax加载后无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆