How to wrap a function around the signature pads #641
-
What I am trying to achieve:
I have been able to achieve 1 and 2 here: I can't figure out how to do number 3. First is the function initSignaturePad, this creates all the bits I want and adds them to the empty div, this works fine. Next are the functions clearPad and readAsSVG, these accept an ID as a parameter. What I want them to do is select the appropriate pad and clear / save it. I don't know enough about JS to get it to work. Is creating functions the correct way to achieve my goal? I also can't figure out how to calculate the ratio and clear the pad on window resize either. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
instead of an - v_clearButton.setAttribute("onclick", 'clearPad("' + vp_DivID + '");');
+ v_clearButton.addEventListener("click", () => { v_signaturePad.clear(); }); and similar with the |
Beta Was this translation helpful? Give feedback.
-
Ah ha! After looking at your example page again I figured out that in the function |
Beta Was this translation helpful? Give feedback.
Ah ha! After looking at your example page again I figured out that in the function
initSignaturePad
I simply needed to useconst
at the front of the line:v_signaturePad = new SignaturePad(v_canvas, {backgroundColor: "rgb(0, 0, 0, 0)"});
Now all the buttons reference the correct object.