Here is how I fixed it:

1) I needed to use remove() instead of empty()

2) To avoid conflicts in the the id, I appended (new Date()).getTime()
to each id to make sure all the id's are unique.

Now when I create a bunch of elements really quickly, they all
disappear eventually.



On Apr 28, 7:10 pm, Code Daemon <ryan.det...@gmail.com> wrote:
> I am creating an element with createElement and then appending it to a
> table and then after a few seconds, deleting it with a call to empty
> (). This works fine
>
> The problem seems to be that every time I create the element, I am
> creating it with the same id and after a few iterations, it fails. It
> will append the element to the table, but will not fadeout or delete
> the element properly.
>
>                                 var obj = document.createElement('span');
>                                 $(obj).attr("id", "fieldstatus")
>                                         .addClass("fieldstatus")
>                                         .html("sending . . .")
>                                         .appendTo( $(this).parent() );
>
>                                 $.post('main/submit', {date: 
> $("#caldate").val(), fieldname: $
> (this).attr("id"), value: $(this).val() },
>                                         function(json){
>                                                 
> $("#fieldstatus").html(json.status);
>                                                 setTimeout(function(){
>                                                                 
> $("#fieldstatus").fadeOut(2000, function(){
>                                                                               
>                           $("#fieldstatus").empty();
>                                                                               
>                           });
>                                                         },
>                                                 1000);
>                                         },
>                                         "json"
>                                 );

Reply via email to