Problem with Rich Text field

Hi everyone,

We have an issue with Rich text field in Wix database.

If we put a long text on a dynamic page (or repeater) we change font, size, … of the text in the editor but when we want to linked our paragraph to our rich text in the database the text lose his settings. So we must use a simple text field and it’s ok but it’s not practice …

Here is the example below

The text setting that we have set (font : Questria)


When it’s live


Thanks in advance for your help.

Kevin Dang
Reverseweb team

Hello,

When you connect a rich text field to a text element, it assumes that you want the text element to have the same styling as the one you set for the rich text field. If you don’t have any special styling, you can indeed use a simple text field.

Why is a simple text field not convenient ? Is it because editing it in the content manager is not convenient ?

If you insist on using a rich text field, you can try to set its value on the relevant text element using code instead of binding them through the ui. Your code will do something like:
$w(‘#dataset1’).onReady(() => {
$w(‘#text1’).text = $w(‘#dataset1’).getCurrentItem().richTextField;
});

(if the text element is inside a repeater, or if the data is updated during page view, you might need some more advanced code.)

I get the following error:

Error: The element selector function (usually $w) cannot be used before the page is ready

Hi Dor Itzhaki,

Thanks for your answer.

Yes, the main reason is for the customers. Most of them want to have their database and just fill in the different fields with their text and we understand them. In fact, the goal is to have the large box of a rich text to put a big text because put a big text in a simple text field isn’t practice for a customer.

The reason I am using the Rich Text field is because I can add more than one paragraph. However, I want to be able to style my text out in the site editor and not in the database rtf editor.

One specific issue I’m running into is I want to have white text on my website. In the Rich text editor I can assign white to the text but then I can’t read it in the editor because it effectively becomes invisible.

@dor-itzhaki This code actually makes the text field display all of the html with tags, not only the formatted text. I don’t think that this is what we’re aiming for. Did you mean .html instead of .text as below?

 $w('#dataset1').onReady(() => {   $w('#text1').html = $w('#dataset1').getCurrentItem().richTextField; }); 

In any case, it seems to be somewhat broken in that the richt text doesn’t get displayed similar to the input at all, as I noted here https://www.wix.com/corvid/forum/community-discussion/rtf-isn-t-displayed-in-text-field-as-it-is-in-the-rtf-user-input-editor

@experimentnoxx

indeed,
$w(‘#text1’).text - will show the value you assign to it as plain text, so html tags will be shown if you set it to a rich text value.
$w(‘#text1’).html - will treat the value as rich text/“html”.

using “.html” with a rich text field should give you the same result as just binding them through the dataset connect panel ui.