jSignature is not a function

5k views Asked by At

I'm trying to use jSignature in my website, but it keeps showing me this error:

Uncaught TypeError: $(...).jSignature is not a function

My code is:

<div id="signature"></div>

$("#signature").jSignature();

I have Jquery 1.11.1:

<script src="https://code.jquery.com/jquery-1.11.1.js"></script>

The Jquery is called before the JS of the function.

I have also tried to call Jquery Mobile, calls like $('#signature').jSignature({'UndoButton':false,color:"#000000",lineWidth:5});, etc but it never works.

Can anyone help ?

2

There are 2 answers

0
Rafael Mateus On

Well, i fixed the problem. The problem was: I had the Jquery 1.12.4 in my plugins file. It would work normal in any page, but with the jSignature it made the JS throw an error. I removed the Jquery from the Plugins ( but keeped the CDN one ) and now it works fine.

I already found many questions about this but never an answer. Hope this helps anyone out there.

Many Thanks

0
Oleksiy Nikonov On

i use jQuery 3.4, had the same issue. Im not quite sure where the problem came from but it was the phantom. First i added all recommended libs to my project and accessed the element as used to:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="/jSignature.min.noconflict.js"></script>
...
$(`#id`).jSignature();

I received the same jSignature is not a function

Afterwards i assumed the problem might be in jQuery version compatability, so added few lines:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="/jSignature.min.noconflict.js"></script>

<script src="https://code.jquery.com/jquery-1.12.4.min.js"
        integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
        crossorigin="anonymous"></script>
<script>
  var jq_1_12 = $.noConflict(true)
</script>
...
jq_1_12(`#id`).jSignature();

it was keeping throw the same error jSignature is not a function.

Finally I removed the last changes and jquery 1.12 import. The problem solved it-self, have no idea what have happened. But the plugin works now without any explicable reason