Created
September 2, 2011 14:31
-
-
Save jhubert/1188744 to your computer and use it in GitHub Desktop.
Delete All Wunderlist Items in a List. Per http://tumble.jeremyhubert.com/post/9706062996/delete-all-tasks-in-a-wunderlist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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.'); | |
} | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great, thanks. Could this be easily modified to remove previously deleted items?