views:

52

answers:

1

i have these two jquery scripts on my html page, one of them loads more results(like pagination), and the other one replies to users messages, just like twitter!

the replies works(inserts username into textbox), when the page is on default, but when i load more results, the loaded results wnt insert the username into the textbox!! these are the two scripts,

the replies 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
    });
});

the loadmore jquery script:

$(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;


});
});

EDIT: when i load more posts, and i click reply the page is refershed, so that ends up with loaded data being hidden again!!

+1  A: 

If the reply button is being replaced by the ajax, this might be a workaround.

$(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();
    });
});

Also... If the status_id, reply_name , replyto info is contained within your reply button, make sure these data exists for each reply button after the more button is clicked.

Brandon
thanks brandon, but this deosnt work, i know the reply buttons are loaded with the info, the posts are generated by the same function!
getaway
it did work thanks mate
getaway