Quantcast
Channel: CQ 5
Viewing all articles
Browse latest Browse all 35

[RICHTEXT] How to process richtext value before it is submitted, richtext adds spacing on a empty tag automatically

$
0
0

The richtext will automatic add a spacing in a empty tag.


Given that, if we input:
<div class="content border-b"><div class="thumbnail"><span class="icon-phone"></span></div></div>

richtext will chage it to:
<div class="content border-b"><div class="thumbnail"><span class="icon-phone">&nbsp</span></div></div>

In some case, we don’t want that.

The solution:

We will add a listener for richtext field to process the value before submit to CRX.

Config:

<teasertext
                       jcr:primaryType="cq:Widget"
                       fieldLabel="Teaser Text"
                       name="./teasertext"
                       removeSingleParagraphContainer="{Boolean}true"
                       xtype="richtext">
                       <rtePlugins jcr:primaryType="nt:unstructured">
                           <misctools
                               jcr:primaryType="nt:unstructured"
                               features="*"/>
                       </rtePlugins>
                       <listeners
       jcr:primaryType="nt:unstructured"
       sync="function(rt, value){ this.el.dom.value = value.replace('&nbsp;', ''); return true;
                        }"/>
</teasertext>


Viewing all articles
Browse latest Browse all 35

Trending Articles