brinley / jSignature

jQuery plugin for adding web signature functionality
http://www.unbolt.net/jSignature
693 stars 530 forks source link

Provide a way to check if jSignature has been started #92

Open ThomasLandauer opened 9 years ago

ThomasLandauer commented 9 years ago

When using jSignature on a hidden div, you have to initialize it only after the div is shown (cause otherwise it takes 0x0 pixels as size). When having the parent div toggle-able (i.e. show/hide repeatedly), when doing "show", you have to check if jSignature has already been started or not (otherwise you get multiple canvas). The only (ugly) solution/workaround I see, is to wrap the initialization in a try...catch block. A cleaner way would be nice :-)

itajackass commented 6 years ago

can you post your workaround?

ThomasLandauer commented 6 years ago

The idea: Start jSignature only if some jSignature command fails. Don't know why I chose getSettings:

try
{
    $('#jSignatureTest').jSignature('getSettings');
}
catch(error)
{
    $('#jSignatureTest').jSignature();
}