jQuery.AjaxFileUpload.js icon indicating copy to clipboard operation
jQuery.AjaxFileUpload.js copied to clipboard

Adapt to use function to call processing rather than upload immediately after choosing file(s)

Open VitoAsaro opened this issue 11 years ago • 4 comments

First of all, thanks for this function; it's excellent! I've been trying to implement this as part of another function, so I'm not using it as part of the jquery document ready:

$(document).ready(function(){ $('input[type="file"]').ajaxfileupload({ 'action': 'uploadfile.cfm' });

I'm attempting to call it from another function that is called by a button on my form: <input type="button" name="btnAction" id="btnAction" value="UPDATE RECORD" onClick="recordAddUpdate(this.form);" >

within the function recordAddUpdate(theForm) to call the ajaxfileupload I have: ... $('#uploadImage').ajaxfileupload({ 'action': 'bsl-editor/bslupload.cfm', 'submit_button': $('#btnAction') }); ...

This works, but only after the "UPDATE RECORD" button is pressed twice I see in your javascript that the first time the function processes, nothing occurs because it's processing the "ajaxUploader-setup" as true and initializing. How can I have it both set up (initialize) and process with only a single call to the function?

Thanks!!

VitoAsaro avatar Mar 11 '14 01:03 VitoAsaro

Try calling .change() on the file input or initializing the ajax upload before the user chooses the file

~ J

(via phone) On Mar 10, 2014 6:07 PM, "VitoAsaro" [email protected] wrote:

First of all, thanks for this function; it's excellent! I've been trying to implement this as part of another function, so I'm not using it as part of the jquery document ready:

$(document).ready(function(){ $('input[type="file"]').ajaxfileupload({ 'action': 'uploadfile.cfm' });

I'm attempting to call it from another function that is called by a button on my form:

within the function recordAddUpdate(theForm) to call the ajaxfileupload I have: ... $('#uploadImage').ajaxfileupload({ 'action': 'bsl-editor/bslupload.cfm', 'submit_button': $('#btnAction') }); ...

This works, but only after the "UPDATE RECORD" button is pressed twice I see in your javascript that the first time the function processes, nothing occurs because it's processing the "ajaxUploader-setup" as true and initializing. How can I have it both initialze and process with only a single call to the function?

Thanks!!

Reply to this email directly or view it on GitHubhttps://github.com/jfeldstein/jQuery.AjaxFileUpload.js/issues/36 .

jfeldstein avatar Mar 11 '14 05:03 jfeldstein

I tried to initialize the ajax upload in the $(document).ready(function), but I think that perhaps because the form resides within a dialog (modal) window, possibly the DOM changes, so the initializing has to occur all over again when the dialog window is showing.

I was able to find a work-around by specifying the submit button used to process the form (calls the data processing proxy function) with: 'submit_button': $('#btnAction') However, the strang thing is that if I didn't specifiy the onComplete AND the onStart functions, nothing would work, even though the onStart function is empty. Any ideas?

VitoAsaro avatar Mar 11 '14 18:03 VitoAsaro

If this is still an issue, could you post the code your using and I'll take a look? On Mar 11, 2014 11:05 AM, "VitoAsaro" [email protected] wrote:

I tried to initialize the ajax upload in the $(document).ready(function), but I think that perhaps because the form resides within a dialog (modal) window, possibly the DOM changes, so the initializing has to occur all over again when the dialog window is showing.

I was able to find a work-around by specifying the submit button used to process the form (calls the data processing proxy function) with: 'submit_button': $('#btnAction') However, the strang thing is that if I didn't specifiy the onComplete AND the onStart functions, nothing would work, even though the onStart function is empty. Any ideas?

Reply to this email directly or view it on GitHubhttps://github.com/jfeldstein/jQuery.AjaxFileUpload.js/issues/36#issuecomment-37328811 .

jfeldstein avatar Mar 26 '14 05:03 jfeldstein

you can use the item 'submit_button':$("#iconsu"),// bind a button click event

mirszhao avatar Jul 27 '15 09:07 mirszhao