4

I am integrating DocuSign clickWrap on my website and It's working fine. I want to save some data when the user clicks on the Agree button. As the ClickWrap modal opens in Iframe and it is hard to get event from Iframe button, So is there any event or some Function which I can use to do this.

I have tried targetting the click event of the button inside the Iframe.

docuSignClick.Clickwrap.render({
          environment: 'https://demo.docusign.net',
          accountId: 'xx29fxxx-de70-xx9x-83xx-xxxxxxx43ddc',
          clickwrapId: 'xxxxxx-03b2-4xxc-xxx1-cxxxxxxcbxx2c',
          clientUserId: 'asdfsadfsdaf'
        }, '#ds-terms-of-service');
YesThatIsMyName
  • 1,585
  • 3
  • 23
  • 30
Harry
  • 43
  • 6

2 Answers2

4

Another way to do this is to listen to the callbacks on the render method:

docuSignClick.Clickwrap.render({
  // ... env, acct, clickwrapId, etc.
  onAgreed: function () {
    // Triggered whenever the agreement is complete or has already been completed
  },
  onDeclined: function () {
  }
}, '#ds-terms-of-service');
Stephen Parish
  • 301
  • 2
  • 6
  • 1
    Also note there is an 'onMustAgree' function call back that may be helpful. – Paul Matovich Jan 23 '20 at 15:35
  • Do you know if it is documented somewhere? Because I couldn't find any documentation... Looking at minified source code, there is also `onAgreeing` and `onDeclining` callbacks – Łukasz K Jun 30 '21 at 06:14
  • Ah yes! These are now documented here: https://developers.docusign.com/docs/click-api/click101/callbacks/ – Stephen Parish Jul 27 '21 at 21:35
2

Here's how I did it. Add an event listener to the window of type 'message'. That event data contains a type field which has the information you are looking for.

   window.addEventListener('message', (e) => {
     if (e.data.type === 'HAS_AGREED') {
       // do something after the click here.
     }
   })
Andrew
  • 41
  • 4