AddThis button will not work inside AJAX, but will work normally

后端 未结 8 831
温柔的废话
温柔的废话 2021-02-04 17:47

Basically, this is what I\'m doing. User visits site, loads \"index.html\" Within index.html, it automatically loads, through AJAX, \"details.html\" into a DIV. I put an ADDTHIS

8条回答
  •  無奈伤痛
    2021-02-04 17:58

    if i understand your question correctly, in the callback of the ajax function, bind the roll-over to the add-this button.

     $.ajax({
       type: "POST",
       url: "some.php",
       data: "name=John&location=Boston",
       success: function(){
         $('.addthis_button').hover(
           function(){
             //do mouse over
           },function(){
             //do mouse out
         });
       }
     });
    

    you can also try

    $('.addthis_button').live('mouseover',function(){//do mouseover});
    $('.addthis_button').live('mouseout',function(){//do mouseout});
    

    i've never used live, but it seems like it would work for you since your add_this button's get created after the $(document).ready()

提交回复
热议问题