Brantron / john_hancock

A Rails gem for custom signature form fields
MIT License
114 stars 27 forks source link

Option to clear the canvas #15

Open Tressa-Sanders opened 4 years ago

Tressa-Sanders commented 4 years ago

Hi! Any way to add and option to "clear" the canvas like the current signature-pad?

Tressa-Sanders commented 4 years ago

I worked it out. I forked the gem and added this to the bottom of the john_hancock.js

function signatureClear() {
  var canvas = document.getElementById("JohnHancock-canvas");
  var context = canvas.getContext("2d");
  context.clearRect(0, 0, canvas.width, canvas.height);
}

Then I used this button code: <button type="button" onclick="signatureClear()">Clear</button>

Brantron commented 2 years ago

Want to open a PR to make this function available?