Solved

The reset of html elements list with more than 5 entries

Posted on 2016-08-09
3
24 Views
Last Modified: 2016-08-15
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
Comment
Question by:obcc-srs
  • 2
3 Comments
 
LVL 7

Expert Comment

by:James Bilous
Comment Utility
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
 

Accepted Solution

by:
obcc-srs earned 0 total points
Comment Utility
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
 

Author Closing Comment

by:obcc-srs
Comment Utility
I made ​​the mistake self dissolved
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now