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

Michael Van Canneyt michael at freepascal.org
Wed Oct 5 11:05:29 CEST 2022



On Wed, 5 Oct 2022, Luca Olivetti via Pas2js wrote:

> El 5/10/22 a les 8:53, Michael Van Canneyt ha escrit:
>>> 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 :)
>
> The law of unintended consequences :-D
>
>> 
>>> 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.
>
> It's not a big issue, now I just use a single space when I want to clear the 
> previous content.

I introduced ClearContents, and now setting an empty text should work if the
widget is already rendered.

Michael.


More information about the Pas2js mailing list