Problem with event binding on clone rows

Problem with event binding on clone rows

Hi ,

I am working on a functionality where on the blur of every cell in a table, I have to trigger a auto-save. For the last cell of the last row I have to add a new clone row with the same blur event binding as in the exiting rows..

Following is the code ..Please help i have stuck for a few days now..

$("#myTable1").live("blur", function(){
       var elementValue = document.getElementById("<%=count%>").value.toString();
       var value = $("#<%=count%>_hidden").attr('value').toString();
       var qualValue = "<%=qualValue %>";
  var sequenceNumber = "<%=sequenceNumber %>";
  var parentAttrbtInstId = "<%=parentAttrbtInstId %>";
  var parentId = "<%=parentId %>";
  var attrbtId = "<%=attrbtId %>";
  var attrbtInstId =  $("#<%=count%>_hidden").attr('attrbtInstId').toString();
  var rootId = "<%=rootId %>";
  var itemId = "<%=item.getItemId()%>";
  var currentCount = "<%=count%>";
  var cellCount = "<%=cellLimit%>";
  var rowId = "row_<%=rowCounter%>";
  var rowCount = <%=rowCounter%>;
 
 

    if(elementValue.toLowerCase() != value.toLowerCase()){
       $.ajax({
      url: "<portlet:resourceURL id='autoSaveAction' />",
           type: 'POST',
           dataType: 'json',
           data: { elementValue:elementValue,qualValue:qualValue,sequenceNumber:sequenceNumber,parentAttrbtInstId:parentAttrbtInstId,parentId:parentId,attrbtId:attrbtId,
            attrbtInstId:attrbtInstId,rootId:rootId,itemId:itemId},
           success : function(response) {
              if (response.status == "SUCCESS") {
                  jsonstr=JSON.stringify(response.result);
var temp=JSON.parse(jsonstr);
$("#<%=count%>_hidden").attr('attrbtInstId',temp.attrInstId);
document.getElementById("<%=count%>_hidden").value = temp.attrValue;
if(currentCount == cellCount){
cloneRow = $("#myTable1 tr:last").clone(true);
   cloneRow.attr({
     'id': function(_, id) { 
return "row_"+(rowCount+1);
     }            
   }).end().appendTo("#myTable1");
   
cloneRow.find("input").each(function() {
   $(this).attr({
     'id': function(_, id) { 
if (id.indexOf("hidden")!= -1){
return currentCount + "_hidden";
}else{
      return ++currentCount;
}
     }             
   });
 }).end().appendTo("#myTable1");
cloneRow.find("select").each(function() {
   $(this).attr({
     'id': function(_, id) {
     if (id.indexOf("hidden")!= -1){
return currentCount + "_hidden";
}else{
      return ++currentCount;
}
}              
   });
 }).end().appendTo("#myTable1");
cloneRow.find("textarea").each(function() {
   $(this).attr({
     'id': function(_, id) {
     if (id.indexOf("hidden")!= -1){
return currentCount + "_hidden";
}else{
      return ++currentCount;
     }              
   });
 }).end().appendTo("#myTable1");
}

} else {
    }
    },
  error:function (xhr, ajaxOptions, thrownError){ 

  }
      });
        }
  });
       });