braintree / braintree-web

A suite of tools for integrating Braintree in the browser
https://developer.paypal.com/braintree/docs/start/hello-client/javascript/v3
MIT License
444 stars 134 forks source link

Is there a way to disable hosted fields? #635

Closed cmacdonnacha closed 2 years ago

cmacdonnacha commented 2 years ago

General information

Issue description

I was wondering if there's a way to disable hosted fields? The reason I'd like to do this is to disable them while my form is being submitted.

cmacdonnacha commented 2 years ago

Just found that there is, see https://braintree.github.io/braintree-web/current/HostedFields.html#setAttribute

    hostedFieldsInstance?.setAttribute(
      {
        field: 'number',
        attribute: 'disabled',
        value: 'true',
      },
      function (attributeErr: any) {
        if (attributeErr) {
          console.error(attributeErr);
        }
      },
    );