0

ニュース コンテナー、ソーシャル ボタン コンテナー、コメント ボックス コンテナーを含むボックスがあります。ボックスの高さは固定されているため、代わりに .append を使用できませんでした。そのボックスを更新したいと思います。問題は、外部の .js ファイルを使用しているため、ボックスで .load を使用するとソーシャル ボタンが機能しないことです。これは可能ですか?

ここに私の箱があります:

<div class="pin-box" id="pinbox_<?php echo $row['articles_id'];?>">
    <div class="box1">
        <?php
            //Script that will echo articles
        ?>


        <hr class="art_line">

        <div class="social_button" id="social_<?php echo $row['articles_id'];?>">

            <span class='st_facebook_large' st_url='<?php echo base_url(); ?>index.php/be_informed/show/<?php echo $row['articles_id']; ?>' displayText='Facebook'></span>
            <span class='st_twitter_large' st_url='<?php echo base_url(); ?>index.php/be_informed/show/<?php echo $row['articles_id']; ?>'  displayText='Tweet'></span>

            <span class='st_linkedin_large' st_url='<?php echo base_url(); ?>index.php/be_informed/show/<?php echo $row['articles_id']; ?>' displayText='LinkedIn'></span>
            <span class='st_googleplus_large' st_url='<?php echo base_url(); ?>index.php/be_informed/show/<?php echo $row['articles_id']; ?>' displayText='Google +'></span>
        </div>
        <div id="space"></div>

        <div id="beinformed_comment">
            <?php
                //Script that will echo comments
            ?>

        </div>
    </div>
</div>

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
        stLight.options({publisher: "751d0899-1764-4d1f-aac0-1bf112ad5cfd",
        doNotHash: false,
        doNotCopy: false, 
        hashAddressBar: false
        });
</script>

これが私のJqueryコードです(私は1.4.2を使用しています):

$('.comment_button_article').live("click",function() 
{

var ID = $(this).attr("id");

var comment= $("#ctextarea"+ID).val();
var user_id= $("#user_id_"+ID).val();
var dataString = 'comment='+ comment + '&msg_id=' + ID + '&user_id=' + user_id;

if(comment=='' | comment=='Enter your comment here')
{
alert("Please Enter a Comment");
}
else

{
$.ajax({
type: "POST",
url: "comment_ajax.php",
data: dataString,
cache: false,
success: function(html){

$('#pinbox_'+ID).load('<?php echo base_url(); ?>index.php/be_informed/index #pinbox_'+ID);

 }
 });

}
return false;
});
4

1 に答える 1

0

私の推測では、実行されていないのはおそらく外部スクリプトです。

コンテンツをページに追加したら (load() 呼び出しのコールバック関数として)、次のように手動でスクリプトを呼び出してみてください。

$.ajax({
    type: "POST",
    url: "comment_ajax.php",
    data: dataString,
    cache: false,
    success: function(html){    
        $('#pinbox_'+ID).load('<?php echo base_url(); ?>index.php/be_informed/index #pinbox_'+ID, function(){
             $.ajax({
                dataType: "script",
                cache: true,
                url: 'http://w.sharethis.com/button/buttons.js'
            });
        });            
     }
});

}

于 2013-04-17T03:59:31.840 に答える