Hi,
I can't figure out why my swfupload_loaded_handler isn't getting called. My plug in seems to be getting initialized fine. I've included the code below and the debug code that gets printed out. Any ideas are greatly appreciated, - Dave
init code:
swf_upload_control = new SWFUpload({
// Backend settings
upload_url: "swffileupload_response.php?UserIdP=6", // Relative to the SWF file, you can use an absolute URL as well.
file_post_name: "file",
// Flash file settings
file_size_limit : "10240000000", // 10 MB
file_types : "*.pdf", // or you could use something like: "*.doc;*.wpd;*.pdf",
file_types_description : "PDF Files",
file_upload_limit : "0", // Even though I only want one file I want the user to be able to try again if an upload fails
file_queue_limit : "1000", // this isn't needed because the upload_limit will automatically place a queue limit
// Event handler settings
swfupload_loaded_handler : myShowUI,
//file_dialog_start_handler : fileDialogStart, // I don't need to override this handler
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
//upload_start_handler : uploadStart, // I could do some client/JavaScript validation here, but I don't need to.
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
// Flash Settings
flash_url : "swfupload_f9.swf", // Relative to this file
// UI settings
swfupload_element_id : "flashUI", // setting for the graceful degradation plugin
degraded_element_id : "degradedUI",
custom_settings : {
progress_target : "fsUploadProgress",
upload_successful : false
},
// Debug settings
debug: true
});
console.log("upload control: " + swf_upload_control);
});
debug console:
----- SWFUPLOAD SETTINGS ----
ID: undefined
upload_url: swffileupload_response.php?UserIdP=6
file_post_name: file
post_params: {
}
file_types: *.pdf
file_types_description: PDF Files
file_size_limit: 10240000000
file_upload_limit: 0
file_queue_limit: 1000
flash_url: swfupload_f9.swf
flash_width: 1px
flash_height: 1px
flash_color: #FFFFFF
debug_enabled: true
swfupload_element_id: flashUI
degraded_element_id: degradedUI
user_swfUploadLoaded_handler: function myShowUI() {
var btnSubmit = document.getElementById("btnSubmit");
var btnCancel = document.getElementById("cancelupload");
btnSubmit.onclick = doSubmit;
btnCancel.onclick = cancelUpload;
btnSubmit.disabled = true;
SWFUpload.swfUploadLoaded.apply(this);
validateForm();
console.log("myshowui activated.");
}
----- SWFUPLOAD SETTINGS END ----
Here's what the event handler looks like:
function myShowUI() {
var btnSubmit = document.getElementById("btnSubmit");
var btnCancel = document.getElementById('cancelupload');
btnSubmit.onclick = doSubmit;
btnCancel.onclick = cancelUpload;
btnSubmit.disabled = true;
SWFUpload.swfUploadLoaded.apply(this); // Let SWFUpload finish loading the UI.
validateForm();
console.log("myshowui activated.");
}
Thanks for your help, - Dave
Nothing Stands Out
Nothing stands out as preventing your loaded handler from firing. Have you tried setting some break points in the JavaScript to see what might be going on?
I like FireBug for FireFox to debug JavaScript.