Skip to content

Instantly share code, notes, and snippets.

@jhubert
Created September 2, 2011 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jhubert/1188744 to your computer and use it in GitHub Desktop.
Save jhubert/1188744 to your computer and use it in GitHub Desktop.
(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.');
}
}
}
}());
@jsouthTo
Copy link

jsouthTo 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