When my user try to upload several files, I trigger a bootbox modal to make him decide on 2 possible options. On the bootbox callback, I want to iterate over a list of file that I get from my file input. The problem is that my file list variable is empty in the callback.
Have a look at the code:
this.loadFiles = function(files){
if (files.length>1){ //here, 'files' is populated
bootbox.dialog({
message: APi18n.__("media_warning_multiple_file_input_modal_message"),
title: TAPi18n.__("media_warning_multiple_file_input_modal_header"),
animate: true,
buttons: {
danger: {
label: TAPi18n.__('cancel'),
className: "btn-default",
},
success: {
label: TAPi18n.__('media_warning_multiple_file_input_modal_ok_button'),
className: "btn-info",
callback: function() {
console.log(files); //here, 'files' is empty
_.each(files, function(file){
//etc.
How can I access to my files
list in my bootbox callback?
May your
files
variable be altered "later on" in the scope of yourloadFiles
function? If so, you should move the alteration part after using it for your dialog: