I am trying to integrate an external javascript library in Vaadin 14.
The library uses callbacks which are defined using the script tag used to set up the library. The mastercard documentation says that the use of callbacks is optional, but you must define those you need in the body of the same script tag that references checkout.js - as follow. These are custom data attributes associated with the tag.
I have included the external library using the @Javascript annotation and the local implementation of the call back functions
How do I specify the customer data attributes in Vaadin?
I have set up the callback function in a local javascript file and followed another post that said to define the functions so that they are in global scope
The documentation uses the html script tag and you can define these attributes in the tag that specifies the external library.
Is there a way to include a standard html file in Vaadin 14 so that I could use the script tag as above and simply import it somehow? The external library creates a “Checkout” object that needs to be globally accessible and the only way I have found to do that is with the @JavaScript annotation import. So all that works and I can use the Checkout object but there is no mechanism in that annotation to specify custom data attributes i.e. data-* items.
Thanks so much for your help - that does solve the problem for me.
Do you know if there is a way to import/include an external js library in a web component so that any variables it would define are visible within the scope of the component only.
It seems anything to do with external js libraries in Vaadin 14 must happen in global scope.