Can´t determine font face with code

Hi Everybody!

I´ve been really racking my brain with this one…

I have one rich text user input field (field key: descricaoImovel). The saved data of this input field should be displayed in a repeater in the text box named #textdescription.
In addition to that, this text box should be limited to displaying 330 characters.

Objective:
I want the character limitation to work at the same time that the field content is displayed with the desired style (font futura light).

Problem:
I cannot get the text box to be displayed in the desired style. Everything else works fine.
I had to use #textdescription.html instead of #textdescription.text because that was the only way to remove the html tags such as

that for whatever reason were being displayed on the repeater.

I would really appreciate any help or suggestions!!! :slight_smile:


Code:

$w.onReady(function () {

    $w("#dataset2").onReady( () => {
        $w("#repeater1").onItemReady( ($item, itemData, index) => {
            $w("#repeater1").forEachItem( ($w) => {
            
let items = $w("#dataset2").getCurrentItem();
if (items["aluguel"]) { $w("#venda0text").hide(); $w("#totalaluguel0text").show() }
else   {$w("#venda0text").show(); $w("#totalaluguel0text").hide() }

//SETTING FONT STYLE
$w("#textdescription").html = '<p class="p1"><span style="color:#858585"><span style="text-align:justify"><span style="font-size:16px"><span style="font-style:normal"><span style="font-weight:300"><span style="font-face:futura">' + $w("#textdescription").text +'</span></span></span></span></span></span></p>'

//Limits characters of text boxes inside repeater
{var Titleitem = itemData.title;
if (Titleitem) {
var shortTitle = Titleitem.substr(0,33);
$item("#texttitle").text = shortTitle + "";
}}

{var EnderecoItem = itemData.enderecoV;
if (EnderecoItem) {
var shortEndereco = EnderecoItem.substr(0,40);
$item("#textaddress").text = shortEndereco + "";
}}

//limits characters and removes html tags
{var DescricaoItem = itemData.descricaoImovel;
if (DescricaoItem) {
let newItem = DescricaoItem.replace("<p></p>", "");
var shortDescription = newItem.substr(0,330);
$item("#textdescription").html = shortDescription + "... ";
}}

});
});
});
});

It’s incorrect to use forEachItem() inside the onItemReady() function. You can only use one or the other.

See the Repeater API for full details.

Hi Yisrael! Thanks for the answer :slight_smile:

I removed the forEachItem() function. Now there´s only the onItemReady(). The character limitation keeps working but I still cannot change the font…

I´ve read all articles I could find about text formatting with corvid but I still can´t find the mistake.

Do you have any advice regarding the formatting? Thanks in advance!!

@joannacastro96
Regarding your post…
I had to use #textdescription .html instead of #textdescription .text because that was the only way to remove the html tags such as

that for whatever reason were being displayed on the repeater.

For working with HTML in your text have a read of this page here.
https://support.wix.com/en/article/corvid-about-formatting-text-elements

Also, if you use the rich text field in a dataset, you can simply set the text up in the field itself with size, style etc, you don’t need to add anything to your code for it.

Then you can simply connect that field to your text box element and it should display it all fine.

However, note that you must leave the text box settings as they are, if you alter the settings in the text box itself then it overrides the rich text settings from the dataset field.