Uncaught TypeError: $(…).code is not a function (Summernote)

Refresh

4 weeks ago

Views

2.6k time

1

I don't know if it's the same error as many got here:

jQuery is not a function erreor

how to fix : Uncaught TypeError: $(...).summernote is not a function #2087

jquery: Uncaught TypeError: $(…).error is not a function

But I'm stuck with it like a gum under my shoe.

Here's the actual error on my Chrome's Developer Tools.

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

I just wish to update Summernote from an older version which has this @ sign error.

Cant write @ using AltGr + @ combination or Ctrl + Alt [email protected] #1406

But then, with the newer version from 0.8.0, it seems that the $(...).code() function is no longer available. Any knows the change I should bring to make it work?

3 answers

1

From documentation:

destroy and code

After v0.7.0, direct jquery methods, destroy and code were removed for avoiding conflict with other jquery libraries. You can call this methods with summernote api.

The direct jQuery code() function has been deprecated and you now have to use the summernote() function:

$('#summernote').summernote();
1

simply works in my case when I added defer

<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote.js" defer></script>

My jquery version is 3.3.1

1

You'll need to call the function differently as stated by their API Docs https://summernote.org/getting-started/#basic-api

$('#summernote').summernote('code');