[Pas2js] How to change a div (or othe widget) content
Luca Olivetti
luca at ventoso.org
Wed Oct 5 09:26:29 CEST 2022
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.
function EnsureNotEmpty(const s:string):string;
begin
if s='' then
result:=' '
else
result:=s
end;
Bye
--
Luca
More information about the Pas2js
mailing list