[Signature] How to use jSignature with the Offline component?

[Signature] How to use jSignature with the Offline component?

  
Forge Component
(11)
Published on 12 Oct by OutSystems Labs
11 votes
Published on 12 Oct by OutSystems Labs
Hi folks,

I've just tried to use jSignature component with the Offline component and faced an issue: how to load a previously saved image back again to the jSignature canvas in an offline-enabled page? I hope this helps anyone in the future and if possible, please comment on any further improvements/alternatives you see fit.

Here's how:
1. Using the jSignature API, in the webblock's Javascript original code, change the export format data to base30 as highlighted below (base30 is one the few formats available in the jSignature minified version allowing both export/import):



2. In your offline application code, when fetching the record using the Offline API, call the jSignature API setData command to replace the signature with your previously saved data, as follows:



In the example above, I'm setting up a function to schedule the signature update in 2secs. This is necessary because the jSignature code still needs to be instantiated before we perform the image load. But I believe there are certainly better ways to do this (for example event-driven?) So le's hear an alternative to this approach. Thanks!