I have a list of items where you can remove them via ajax. Now, when I remove the last item on said list, I'd like it to show a message. I've tried several things, such as asking if the container div has children, but it fails. The code would be something like this:
$.ajax({
type: "DELETE",
data: {
_token : token
},
url: "item/" + id,
success: function (data) {
$("#item-" + id).fadeOut("normal", function() {
$(this).remove();
$("#item-list").not(':parent').text("Nothing to do.");
});
},
error: function (data) {
console.log('Error:', data);
}
});