Skip to content

Instantly share code, notes, and snippets.

@pavelpower
Created October 1, 2013 11:12
Show Gist options
  • Save pavelpower/6776961 to your computer and use it in GitHub Desktop.
Save pavelpower/6776961 to your computer and use it in GitHub Desktop.
multiselect requester
function sendMultiRequestFor(userIds, cfg, method) {
var i = 1, width = 300, len = userIds.length, step = width / len,
dataFn = cfg.dataFn || function(userId) {
return {
user_id: userId
}
};
Ext.MessageBox.show({
title: cfg.msgBox.title,
msg: cfg.msgBox.msg,
progressText: cfg.msgBox.progressText,
width: width,
progress: true,
closable: false
});
function progress() {
Ext.MessageBox.updateProgress(i * step, Math.round(i * 100/ len) + '% been completed!');
i++;
}
if (method !== 'post' && method !== 'update') {
return $.when.apply(this, $.map(userIds, function(userId) {
return $[method](cfg.url.supplant(dataFn(userId)), progress);
}));
} else {
return $.when.apply(this, $.map(userIds, function(userId) {
return $.post(cfg.url, dataFn(userId), progress);
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment