Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove tinymce default html

Is it possible to remove tinymce default html?

<p><br data-mce-bogus="1"></p>
like image 206
Diogo Cardoso Avatar asked Sep 08 '11 11:09

Diogo Cardoso


2 Answers

Those bogus elements are usually getting removed onSave or getContent(). You won't be able to see them using the code plugin eighter.

The br in this case is necessary in Firefox in order to be able to click into the paragraph.

like image 186
Thariama Avatar answered Sep 23 '22 09:09

Thariama


A workaround is to apply a "untag" function over the iframe text, to make sure the user wrote something that is NOT tags, I mean, some innerHTML or pure text:

function untag(text){       
   var t = "" + text;                     
   t = t.replace(/<[^>]+>/g, "");  
   return t;
}

var msg = $('your_mce_iframe_id').html();

if( untag(msg) != "" ){
    // user wrote anything, validation ok
}
like image 21
Sergio Abreu Avatar answered Sep 22 '22 09:09

Sergio Abreu