I am using tinymce 4.0.1 and it automatically adds p tags when you either start typing or hit enter. How can I dynamically remove these p tags and then reinsert the content
Are you looking for: forced_root_block : '', force_br_newlines : true, force_p_newlines : false,
You can remove "p" tag by adding forced_root_block : false
to your tinymce setup or you can hide the status bar by statusbar: false
How about
$("p").each(function(){$(this).parent().append($(this).html()); $(this).remove()})
Can you simply tweak what TinyMCE puts into the database when you display it? See my post for the same thing for Rails.
var str = "{TinyMCE HTML string}"; /* however you get it */
str = str.replace(/^\<p\>/,"").replace(/\<\/p\>$/,"");
Here you are removing the beginning and ending p tag of the whole TinyMCE HTML when you display it. Doesn't mess with other p tags or the TinyMCE config.
Explanation of the regex expression (removed \'s for ease of reading):
^<p> - find <p> at the start of the string (^) and replace it with nothing.
</p>$ - find </p> at the end of the string ($) and replace it with nothing.
Hope this helps.
Add this only in call javascript:
forced_root_block : false