我有一个包含新闻容器、社交按钮容器和评论框容器的盒子。盒子的高度是固定的,所以我不能使用 .append 而不是我想刷新那个盒子。问题是当我在框中使用 .load 时社交按钮不起作用,因为它使用的是外部 .js 文件。这可能吗?
这是我的盒子:
<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;
});