• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 68
  • Last Modified:

The reset of html elements list with more than 5 entries

Hello everyone,

I using jquery to delete list Elements.

If i want to delete more als 5 Elements, can Become the first no longer deleted .
Why?
 done: function (e, data) {
                    $('#fileupload').prop("disabled", false);
                    $('#senden').prop("disabled", false);
                    $.each(data.result.files, function (index, file) {
                        id = file.name.replace(" ", "");
                        id = id.replace(/[^a-zA-Z0-9]/g, '_');
                        id = id.replace("_", "");
                        $('#progress .bar').text("");
                        $('<ul>').html("<li id='li" + id + "' ><tr ><td><a id='" + id + "' class='ui-btn ui-icon-delete ui-btn-icon-left'>" + file.name + "</a></td></tr></li>").appendTo("#datalist");

                        deletefile(file.name, id);
                        console.log(id);

                    });


                },

Open in new window


   function deletefile(name, id)
        {
            $('#' + id).click(function () {
                $.post("obcctransfer.php", {ceck: "delete", id: name}, function (data) {
                    $('#li' + id).html("");
                    if ($('#li' + id).length) {
                        alert("Das DIV mit der ID '#li' + id existiert");
                        alert(id);
                    }
                    console.log(id);
                });
            });
        }

Open in new window

0
obcc-srs
Asked:
obcc-srs
  • 2
1 Solution
 
James BilousSoftware EngineerCommented:
I'm having trouble understanding this part of your question:

If i want to delete more als 5 Elements, can Become the first no longer deleted .

Are you saying that when your done callback function is called with more than 5 elements in the data.results.file property, all but one of the list items in your html are removed?
0
 
obcc-srsAuthor Commented:
done callback is execuded after every uploaded file.
in there it initialize these function deletefile().

And in there  "$('#li' + id).html("");" Do not reset the first and second entry. If that all was more than 5 times running. The IDs are available
0
 
obcc-srsAuthor Commented:
I made ​​the mistake self dissolved
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now