spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
815 stars 256 forks source link

ed.on is not a function #239

Open gazayas opened 6 years ago

gazayas commented 6 years ago

When doing setup in the tinymce.yml file or directly on the page with tinymce.init({ ... }), it will log the editor to the console:

setup: function(ed) { console.log(ed) }

but if I try to use ed.on() it just says that ed.on is not a function.

If I remove setup, the editor shows up just fine. I also uninstalled the gem and just used tinymce hardcoded into the view, and it works just fine with setup and ed.on

Here's how my tinymce.yml file looks like:

toolbar:
  - italic
menubar: false
selector: 'textarea'
height: 275
forced_root_block : ""
setup: function(ed) {
    ed.on('init', function()
    {
      this.getDoc().body.style.fontSize = '16px';
    });
  }
spohlenz commented 6 years ago

What gem version are you using? Your example seems to work fine for me with tinymce-rails 4.7.9.

gazayas commented 6 years ago

Yeah, running 4.7.9 I tried it with a 3.x version and the same thing happened.

Must be something over here. I'll look a little deeper into it.

The error looks like this by the way: 2018-03-19 6 03 44

gazayas commented 6 years ago

Hmm, going through my commits it definitely seemed to be the version change. I was running 4.4.1 earlier according to gemfile.lock Started having issues when it bumped up to 4.7.9 But like I said I tried it with 3.5.11.1, and it said ed. is not a function too.

Strange. Anyways I put this in my gemfile and it's working without changing any of the code, so I'll stick to it: gem 'tinymce-rails', '~> 4.4.1'

Sorry for the trouble!