Search code examples
javascriptjqueryfroala

Uncaught TypeError: $(...).froalaEditor is not a function// solution is found but not sure how to use it


I just simply want to use froala text editor on my site, but I get Uncaught TypeError: $(...).froalaEditor is not a function.

I googled it and found the solution here but I don't know how to use this source. Mainly because I don't have this anywhere in my code

var $ = require('jquery');
require('node_modules/froala-editor/js/froala_editor.min.js');

$(function() {
  var $target = $('<div>').appendTo('body');
  $target.froalaEditor()
});

I simply followed the documentation, https://github.com/froala/wysiwyg-editor. I used {{form.media}} at the top to use it but on console I get the above mentioned error. Can someone please tell me how to use the solution in github?


Solution

  • require('node_modules/froala-editor/js/froala_editor.min.js')($);

    You see at the end?