question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: element.summernote is not a function

See original GitHub issue

I’m using Yeoman Angular-Fullstack generator, this is my first time using webpack.

This error has given me headaches for a lot of hours: angular.js:13920TypeError: element.summernote is not a function

It is supposed to appear when the dependencies aren’t loaded in the right order. I can’t get it to work even with my app.ts looking like this:

var $ = require('jquery');

import 'bootstrap/dist/css/bootstrap.css';
const bootstrap = require('bootstrap');

const codemirror = require("codemirror");

import 'summernote/dist/summernote.css';
const summernote = require('summernote');


const angular = require('angular');
// import ngAnimate from 'angular-animate';
const ngCookies = require('angular-cookies');
const ngResource = require('angular-resource');
const ngSanitize = require('angular-sanitize');

const uiRouter = require('angular-ui-router');
const uiBootstrap = require('angular-ui-bootstrap');

const ngSummernote = require('angular-summernote');

const lodash = require('lodash');`

The answer could be something pretty simple but I’m running out of ideas. Any help would be appreciated

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
gzuzkstrocommented, Oct 29, 2016

I solved it by adding $() to the element before activate is called (also, $ is an alias for jQuery in webpack config).

//Directive in angular-summernote.js

if (!ngModel) {
            transclude(scope, function(clone, scope) {
              // to prevent binding to angular scope (It require `tranclude: 'element'`)
              element.append(clone.html());
            });
              console.log(element);
            summernoteController.activate(scope, $(element), ngModel);
          } else {
            var clearWatch = scope.$watch(function() { return ngModel.$viewValue; }, function(value) {
              clearWatch();
              element.append(value);
                console.log(element);
              summernoteController.activate(scope, $(element), ngModel);
            }, true);
          }

This is my first attemp on using webpack so maybe there’s a way of solving it without changing wrapper code.

3reactions
Celadoracommented, Feb 19, 2018

The problem for us was a missing bower.json file. Adding this file corrected the problem.


{
  "name": "summernote",
  "homepage": "https://github.com/summernote/summernote",
  "version": "0.8.9",
  "main": [
        "./dist/summernote.js",
        "./dist/summernote.css"
  ],
  "_release": "0.8.9",
  "_resolution": {
    "type": "version",
    "tag": "v0.8.9",
    "commit": "55ce8b405ab1ff4fd86ae147af7e74d97fd9d738"
  },
  "_source": "https://github.com/summernote/summernote.git",
  "_target": "~0.8.0",
  "_originalSource": "summernote"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR TypeError: _this._$element.summernote is not a ...
I have error ERROR TypeError: _this._$element.summernote is not a function in Installation Install ngx-summernote and dependencies: npm ...
Read more >
TypeError: element.summernote is not a function
summernote is not a function ". It works normally if adding libraries as script tags, without any build tool, but with Webpack it...
Read more >
Uncaught TypeError: $(...).summernote is not a function
summernote is not a function error. This error occurs when you try to call the summernote method on an element without including script...
Read more >
Summernote not working - Laracasts
after following the documentation of summernote how to implement it i am only seeing this ... summernote is not a function(…) ... Uncaught...
Read more >
Examples - Summernote
Super Simple WYSIWYG Editor on Bootstrap Summernote is a JavaScript ... This function get item as first argument and should return Element or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found