[Pas2js] How to change a div (or othe widget) content

Michael Van Canneyt michael at freepascal.org
Wed Oct 5 08:53:58 CEST 2022



On Tue, 4 Oct 2022, Luca Olivetti via Pas2js wrote:

> El 4/10/22 a les 9:59, Luca Olivetti via Pas2js ha escrit:
>> El 4/10/22 a les 9:52, Michael Van Canneyt ha escrit:
>>> 
>>> 
>>> On Tue, 4 Oct 2022, Luca Olivetti via Pas2js wrote:
>>> 
>>>> El 3/10/22 a les 17:35, Michael Van Canneyt via Pas2js ha escrit:
>>>> 
>>>>> 
>>>>> I have changed this.
>>>>> 
>>>>> I have also added TextMode as a property so you can choose between 
>>>>> InnerText
>>>>> and InnerHTML
>>>> 
>>>> 
>>>> Unfortunately you left out the "if FTextContent<>''" which broke my page 
>>>> (it empties a div hence later it doesn't find the element that were 
>>>> there).
>>> 
>>> I understood from your original mail that you wanted that particular part 
>>> gone ?
>> 
>> I must have expressed myself poorly, I just wanted a way to modify the 
>> content, i.e. what you did in a later commit
>> 
>> https://gitlab.com/freepascal.org/fpc/pas2js/-/commit/ad8c36e807de50be099dd0bf16e346fd21b0edc9 
>> 
>>> 
>>> I reinstated it.
>> 
>> Thank you.
>
>
> Aagh, now I see where the confusion came from: in one message I told that, if 
> I assign and empty content, the element would keep the old one, so you 
> removed the check, but then when I create the widget it would empty the 
> content that it got from the html.

Yes, that's the consequence :)

> I guess I can't have my cake and eat it too, unless you could differentiate 
> the two cases (i.e. initial assignment, when you just got the element from 
> the html, and subsequent assignments).

I've long been thinking to create a 'ClearContent' method, maybe this is a
good occasion. It could actually set the HTML innertext/html, and for this
widget then also set the textcontent to empty.

But first I'll think about how to solve the detection of the initial
setting, probably there is a way.

Michael.


More information about the Pas2js mailing list