purtuga / SPWidgets

Sharepoint Custom UI Widgets
74 stars 34 forks source link

Document Upload - Hiding the popping form when there are mandatory fields in the library #68

Closed maikbergerhoff closed 8 years ago

maikbergerhoff commented 8 years ago

I started using your upload-component and it's working pretty good.

I have on question, though: Is there an opportunity to hide the form popping up after the file has been uploaded when there are mandatory fields in the target doc-library?

I attached a screenshot of the form I am talking about.

You could ask yourself: Why shouldn't the mandatory fields be filled by the uploading user? But as it is possible to upload files without filling the mandatory fields (by hitting 'cancel' in the popping form) I wanted to ask whether it is possible to just hide this form.

I am using Sharepoint 2010 and Internet Explorer 8.

Thanks in advance!

screenshot

purtuga commented 8 years ago

Hi @maikbergerhoff Yes, it is possible to hide the form. You will need to use the onPageChange option and after getting an indication there (via the event object that the callback to this param is given), you should use JQuery to find the "Cancel" button and trigger a click on it manually..

Take a look at the example 2 in the documentation for this widget: https://github.com/purtuga/SPWidgets/blob/master/documentation/SPWidgets.SPControlUpload.md

It shows how to use the event object given to the callback. There is also documentation there about the event object itself.

Hope this helps.

/Paul

NoahMueller commented 8 years ago

Hey there, first of all: Thanks for the fast answer!

I am one of @maikbergerhoff 's co-workers and tried your advice.

However I figured out that the onPageChange event triggers right before the iFrame is filled with fields and buttons. This results in the fact, that the buttons are not there yet (and therefore they are not clickable). You can see the point of debugging in the screenshot.

Did I do something wrong or is the event really triggering to early? And if it is so, is there another opportunity to click the 'cancel'-button?

Thanks in advance! eventtooearly2

purtuga commented 8 years ago

Look at the example I have in the docs again (#2).  The custom event object has information on what stage the upload is in and if I remember correctly, you need to only execute your code after ev.state is equal to "3".  Also, the event object gives you a property that actually points to the Document (form) that is displayed inside the iframe (ev.page I think). 

Paul -- sent from mobile