I’m trying to use Ben Alman’s jquery plugin debounce which will limit the times my function will get called. https://github.com/cowboy/jquery-throttle-debounce
However, saveEditor get’s called each time(and many times during one keypress. The main issue is that saveEditor is getting called multiple times. I want to limit it to only be called once every delay. That’s why I’m using the plugin. If anyone has a better implementation, please share.
Here is my code during TinyMCE initialization:
'config' => 'setup : $.debounce(1000, true, function(ed) {
ed.onEvent.add(function(ed, e) {
if( ((e.ctrlKey==true || e.metaKey==true)))
{
saveEditor(this.editorId);
e.returnValue = false;
e.preventDefault();
}
});
ed.onClick.add(function(ed) {
lastClickedEditor = this.editorId;
});
})
Somehow it looks as if the save operation gets called for every editor instance on your page.
I do not know what your function call
saveEditor(this.editorId);does (?). But it is possible to have only one editor save usingeditor.save();(link to API).