I am using the SP file attachment modal to attach files to list items and I am having an issue with trying to target the OK button click event.

I know I can use the dialog callback once it finishes, but how can I target it this at the start once the user clicks the button to upload the file?

The reason being is I have a custom loader where I want to fade the dialog-content out, fade in my loader and then when it completes in the callback, fade the loader out.

I cannot figure out how to get access to the button click event though, which is causing an issue because depending on how big the file is, it can take a minute or more to upload. In the meantime the users are sitting there with no prompts, no nothing to let them know what is going on and I get the feeling they might not wait for it to finish and just try and reload the page thinking it froze. Any help here?

To be more clear I am using SharePoint Online and am using a custom solution in angular js/jQuery as I don't have access to SharePoint Designer, so no SP Designer tips or tricks will work for me, I need a solution in javascript...


I supposed your problem is because the DOM element for the button is created in dinamic way.

If you are using jQuery, you can attach one event to the complet body to target the new one elements created.

Some like this.

$('body').on('click', 'button.myclass', function() {
    // do something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.