GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.97k stars 399 forks source link

Triggering onChange event on the target input #474

Open way5 opened 6 years ago

way5 commented 6 years ago

Need your help to figure out how to get called $('target.input').onChange when editor stops, saves, etc... Couldn't find this feature / option in the manual. Thanks!

PS: Also, could I count on having onChange event just without stop the editor? The default HTML form behavior when you change an element is ok for me.

anthonyjb commented 6 years ago

Hi @way5 - Sorry I'm not entirely sure what you're after from your description above, if you'd like to execute code when the editor starts/stops maybe this example can help:

const editor = ContentTools.EditorApp.get()

editor.addEventListener('start', (ev) => {
    // ... do something
 })

editor.addEventListener('stop', (ev) => {
    // ... do something
})
way5 commented 6 years ago

HI @anthonyjb! Just as an example:

var editor = ContentTools.EditorApp.get(); editor.editor.addEventListener('saved', function(ev) { ev.detail().regions.regionName.trigger('change'); });

It would be perfect to somehow figure out this functionality via code...