You can add a global timeout function that every two seconds (the interval depends on you) checks:
function updateCardIfDirty() { if (tinyMCE.isDirty()) {
A cleaner solution might be checking every time they make changes to the tinyMCE editor. This can be done using the onChange() tinyMCE event :
tinyMCE.init({ ... setup : function(ed) { ed.onChange.add(function(ed, l) {
The disadvantage of the first approach is that it will be executed every 2 seconds, even if they do not edit the map for an hour. The disadvantage of the second approach is that if they make 10 changes in 1 second, it will retransmit the card 10 times per second.
So, let's try the third approach, which will get the best of both worlds, and lose both of the shortcomings that we mentioned:
tinyMCE.init({ ... setup : function(ed) { ed.onChange.add(function(ed, l) { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(function(){ timeout=null; rerenderCard(); }, 1000); }); } });
davin source share