What about just attaching the code you need during insert..

>     // Add item to list
>     $('.additem').click(function(){
>         var template = $($(this).prev().get(0)).clone();
>         template.insertBefore($(this));
>         return false;
>     });

Becomes...

// Add item to list
$('.additem').click(function(){
      var template = $($(this).prev().get(0)).clone();
      template.insertBefore($(this)).click(function(){
            $(this).prev().parent().remove();
            return false;
      });
      return false;
});

Just bind the same behavior DURING the insert process.. It's probably
cleaner to put the remove() line in its own function and just passing
the ref, but it should be effective.

Reply via email to