Ceci est la suite de la précédente question stackoverflow jQuery j'ai demandé, mais je ne pense pas que la ligne qui dit:Activation événement en direct après est mort
$(".insert").live("click", insertHandler);
travaille.
<!DOCTYPE HTML>
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function insertHandler(currentRow) {
var newRow = currentRow.clone(true);
newRow.children('td:last').empty().append('<input name="myid" />');
currentRow.after(newRow);
document.myForm.myid.focus();
}
function OnLoad() {
$('input[name="myid"]').live('focusout', function() {
var myValue = $(this).val();
var currentCell = $(this).parents("td");
currentCell.empty().append(myValue);
$(".insert").live("click", insertHandler); // I need help here
});
$('.insert').live('click', function() {
$('.insert').die();
var currentRow = $(this).parents("tr:first");
insertHandler(currentRow);
});
$('.delete').live('click', function() {
if (confirm("Are you sure?")) {
$(this).parents("tr").remove();
}
});
}
google.load("jquery", "1");
google.setOnLoadCallback(OnLoad);
</script>
</head>
<body>
<form name="myForm">
<table border="1">
<tr>
<td class="insert">Add</td>
<td class="delete">Erase</td>
<td>Sample data goes here</td>
</tr>
</table>
<input name="Other">
</form>
</body>
</html>
Je veux que l'utilisateur soit en mesure d'ajouter une nouvelle ligne, mais pas cliquez sur « Ajouter » encore et encore sans cesse. Avec votre aide, j'ai désactivé l'événement "Ajouter", mais maintenant j'ai de la difficulté à revenir en arrière.