Create a gist now

Instantly share code, notes, and snippets.

(function () {
function deleteAll() {
var list = $('ul#list'),
list_id = parseInt($(list[0]).attr('rel'), 10),
list_name = $('#list' + list_id + ' b').html();
if (list_id > 0) {
if (confirm('Are you sure you want to delete all the items in ' + list_name)) {
list.find('li').each(function () {
var id = parseInt($(this).attr('id'), 10),
task = { id: id, list_id: list_id, deleted: 1 };
$.ajax({
url: '/ajax/tasks/update/',
type: 'POST',
data: {'task': JSON.stringify(task)},
success: function (response_data, text, xhrobject) {
var response = ajaxresponse.check(response_data);
if (response.status === 'success') {
wunderlist.updateBadgeCount();
}
}
});
});
alert('Done. Please reload the page.');
}
}
}
}());
@jwsobeck
jwsobeck commented Nov 4, 2011

This is great, thanks. Could this be easily modified to remove previously deleted items?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment