Laurence Tuck
Laurence Tuck

Reputation: 420

Update text field with TinyMce Content on submit

Ive added the TinyMCE editor to a 'dynamic' form that receives an item to update and updates the item div with the text one enters into TinyMce. This works fine and updates the div. My save function uses the text from the div and not tinymce. My problem is that when using any of the formatting functions i.e. H2, unless you hit enter, the div does not get updated.

any ideas?

here is my code:

setup : function(ed) {
ed.onKeyUp.add(function(ed, e) {
  var articlebody = tinyMCE.activeEditor.getContent({format : 'raw'});                    
  $("#article_body").html(articlebody);                       
}

Upvotes: 0

Views: 993

Answers (1)

Brett Henderson
Brett Henderson

Reputation: 1684

The problem is that when the end user changes the format (like adding a H2) that's not going to trigger the "keyUp" event you use to update your "*#article_body*" div with.

You could use the onChange event as this fires when an undo level is added and should cover not only new content, but also formatting changes.

Upvotes: 1

Related Questions