I have been stuck on this issue for longer than I care to mention, and no matter what I have tried, I have not been able to get it working.
Short version is I am attempting to bind to the click/submit event of the aspnetForm that controls the uploading of a file using the SharePoint AttachFile modal.
It is inside an Iframe, which I grab using the ‘load’ event to wait until it loads and then bind to a variable called iBody(console log is below). The object itself is in the [0] of this. I can then do stuff like iBody[0].aspnetForm.ctl00$ PlaceHolderMain$ btnOK
to grab the input/button, but I cannot bind to it for whatever reason. Neither the submit nor click event work.
Then I realized that it is an aspnetForm and the OK button is the submit event for the form. So in the second connosle.log, you see I have bound my iContent variable to the aspnetForm. However I have not been able to bind to either of the submit or onsubmit events of the form itself.
I am at a total loss right now with this. I can see the form, grab the input element itself that acts as the OK button but cannot attach an event handler to it. Nothing seems to work—I have tried $ ('#ctl00_PlaceHolderMain_btnOK').click/submit/onsubmit
to attach to the input/button, I have tried using $ ('#aspnetForm').on('click'/'submit'/'onsubmit', function() { //do stuff once it's clicked });
to attach to the form itself, but nothing seems to work.
Basically I am helpless to do anything from the time the user presses the OK button to upload the file until the time it takes the file to finish uploading and I get the result dialog callback, which can be upwards of a minute depending on the file size. I want to display a notification to the user the file is indeed uploading instead of having it just sit there and leave the user to wonder what is going on.
Please help with this!!