Created
November 10, 2011 21:10
-
-
Save rquigley/1356241 to your computer and use it in GitHub Desktop.
hahaha
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
deleteMessageThreads: function(threadUrls) { | |
var csrfToken = $('#csrf').find('[name=csrfmiddlewaretoken]').get(0).value; | |
var messagePks = []; | |
var asyncEvent = function() { | |
var dfd = new jQuery.Deferred(); | |
var numDone = 0; | |
var numTotal = threadUrls.length; | |
var ajaxCalls = _.map(threadUrls, function(url) { | |
$.get(url, function(resp) { | |
var ids = _.map($(resp).find('.msg-list-itm'), function(i) { | |
return $(i).data('message-id'); | |
}); | |
messagePks = _.union(messagePks, ids); | |
numDone += 1; | |
if (numDone === numTotal) { | |
dfd.resolve(); | |
} | |
}) | |
}); | |
return dfd.promise(); | |
} | |
$.when(asyncEvent()).done(function() { | |
var data = $.param({ | |
csrfmiddlewaretoken: csrfToken, | |
message_pks: messagePks | |
}, true); | |
$.post('/account/messages/remove/', | |
data, | |
function(data) { | |
window.location.reload(); | |
} | |
); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment