onChange Callback
Fires whenever the completedFiles array changes (upload complete or file removed).
(function() {
var logEl = document.getElementById('log');
function log(m) { var d = document.createElement('div'); d.className='pkg-log-entry'; d.textContent=m; logEl.appendChild(d); logEl.scrollTop=logEl.scrollHeight; }
new MultipleUpload('#demo', {
uploadUrl: '/api/upload',
multiple: true,
removable: true,
onChange: function(files) {
log('Files changed. Count: ' + files.length);
files.forEach(function(f) { log(' - ' + f.fileName + ' (' + (f.guid||'no guid') + ')'); });
}
});
})();The queue changed shape
onChange fires whenever the queue is modified — files added, removed, reordered, completed. It is the coarse hook: use it to keep a count, enable or disable a submit button, or mark a form dirty, rather than to react to one specific file.
Pick the right granularity
For per-file work, onFileAdded, onTaskComplete and onQueueRemove tell you what actually happened and hand you the task. Doing per-file logic inside onChange means re-deriving the change by comparing against your own previous copy of the queue, which is work the specific callbacks have already done for you.