word count function is working fine only when I am typing something in text area when I try to delete words with backspace word count is not working.
            Asked
            
        
        
            Active
            
        
            Viewed 284 times
        
    1
            
            
        
        Jay_Pandya
        
- 137
 - 9
 
1 Answers
2
            From the wordcount plugin source you can see that the word count only gets updated on 'setContent', 'beforeaddUndo' and if the user types a space.
editor.on('setcontent beforeaddundo', update);
editor.on('keyup', function(e) {
    if (e.keyCode == 32) {
        update();
    }
});
To extend this behaviour you can update the count on other events too. To add the update of the wordcount on Delete and Backspace key use the tinymce config parameter as follows:
setup: function(ed){
  ed.on('keyup', function(e) {
    if (e.keyCode == 46 || e.keyCode == 8)
    {
      var wc_bar = ed.theme.panel.find('#wordcount');
      if (wc_bar) {
          wc_bar.text(['Words: {0}', ed.plugins.wordcount.getCount()]);
      }
    }
  });
}
Here is a working tinymce fiddle: http://fiddle.tinymce.com/pnfaab
        Thariama
        
- 50,002
 - 13
 - 138
 - 166
 
- 
                    1Thanks @Thariama i really appreciate your help..and it worked just need to integrate this function to my `rails` tinymce's config file for this. – Jay_Pandya Jan 07 '16 at 12:05
 - 
                    2glad to have been able to help – Thariama Jan 07 '16 at 12:06