i have the following scenario:
i have a table which has trs which all have a "copy" link when the user clicks the "copy" link the parent tr is cloned and appended to the table, now the problem is, first time the click event fires okay, but 2nd time it fires two times, third time it fires three times and so on, and also as i have "cloned" the tr, i want to bind the click function to this cloned tr's "copy" link too, any solutions?
i have tried $('.copy-row-link').unbind('click').click(function() { /* the code */ });
i have read similiar qns but they doesn't seem to solve my problem
my code :
$(".copy-row-link").unbind('click').bind('click', function(e)
{
var strdata = 'class="viewtext" style="background-color:#FFFFFF;" id="highlight1733" onMouseOver="highlight(\'1733\');" onMouseOut="removehighlight(\'1733\');'
//var newTr = currTr.clone(true).addClass("viewtext").css( { "backgroundColor" : "#FFFFFF" } ).attr(;
var id = currTr.attr("id"); // currTr is set previously
var newId = id.replace("highlight", "");
//alert( newId );
newId = parseInt( newId );
newId += 1;
var newTr = currTr.clone()
.addClass("viewtext newAddedRow")
.css("backgroundColor", "#FFFFFF")
.attr('id', "highlight" + newId.toString() )
.mouseover(
function() {
highlight( newId );
}
)
.mouseout(
function() {
removehighlight( newId );
}
);
//newTr.appendTo( currTb );
newTr.hide();
newTr.insertAfter( "#" + id );
newTr.fadeIn(100);
newTr.attr('id', newId);
//e.stopPropagation();
//e.preventDefault();
//e.stopImmediatePropagation();
bindToTr(); // Bind to Tr calls this function again
return false;
});