2010-09-21 118 views
0

我在我的html页面上有这两个jquery脚本,其中一个加载更多结果(如分页),另一个回复用户消息,就像twitter一样!这个jquery出了什么问题?

回复作品(inserts username into textbox),当页面是默认的,但是当我加载更多结果时,加载的结果wnt将用户名插入文本框!这是两个脚本,

答复的jQuery:

function insertParamIntoField(anchor, param, field) { 
     var query = anchor.search.substring(1, anchor.search.length).split('&'); 

     for(var i = 0, kv; i < query.length; i++) { 
      kv = query[i].split('=', 2); 
      if (kv[0] == param) { 
      field.val(kv[1]); 
      return; 
      } 
     } 
    } 


$(function() { 
    $("a.reply").click(function (e) { 

     insertParamIntoField(this,"status_id",$("#status_id")); 
     insertParamIntoField(this,"reply_name",$("#reply_name")); 
     insertParamIntoField(this, "replyto", $("#inputField")); 



    $("#inputField").focus() 

$("#inputField").val($("#inputField").val() + ' '); 


    e.preventDefault(); 
     return false; // prevent default action 
    }); 
}); 

的loadmore jQuery脚本:

$(function() { 
//More Button 
$('.more').live("click",function() 
{ 
var ID = $(this).attr("id"); 
if(ID) 
{ 
$("#more"+ID).html('<img src="moreajax.gif" />'); 

    $.ajax({ 
     type: "POST", 
     url: "ajax_more.php", 
     data: "lastmsg="+ ID, 
     cache: false, 
     success: function(html){ 
    $("ul.statuses").append(html); 
    $("#more" + ID).remove(); 

     } 
    }); 
    } 
else 
{ 
    $(".morebox").html('The End'); 

} 


return false; 


}); 
}); 

编辑:当我加载更多的岗位,我点击回复页面被调用,以便加载的数据再次被隐藏起来!

+0

有人吗? :((((((! – getaway 2010-09-21 08:49:36

+0

pleaaaaaaaaaaaaaaase someone – getaway 2010-09-21 09:52:40

+0

是否将回复按钮替换为从ajax调用中返回的html?如果它正在被替换......无论您附加到原始回复按钮的任何点击处理器将不存在 – bcm 2010-09-21 10:12:54

回答

1

如果答复按钮被ajax替换,这可能是一种解决方法。

$(function() { 
    $("a.reply").live(click, function (e) { 
     insertParamIntoField(this,"status_id",$("#status_id")); 
     insertParamIntoField(this,"reply_name",$("#reply_name")); 
     insertParamIntoField(this, "replyto", $("#inputField")); 
     $("#inputField").val($("#inputField").val() + ' ').focus(); 
     e.preventDefault(); 
    }); 
}); 

而且......如果STATUS_ID,reply_name,信息的replyTo包含您的回复按钮内,确保这些数据对每个回复按钮被点击更多按钮后存在。

+0

谢谢布兰登,但这个deosnt工作,我知道答复按钮加载信息,帖子是由相同的功能生成的! – getaway 2010-09-21 10:26:10

+0

它确实工作感谢队友 – getaway 2010-09-21 11:26:19