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

Luca Olivetti luca at ventoso.org
Mon Oct 3 20:20:14 CEST 2022

El 3/10/22 a les 17:35, Michael Van Canneyt via Pas2js ha escrit:

>> If I use a TTagWidget instead, I can use TextContent (however if I set 
>> it to '' it will keep the previous content).
> I have changed this.
> I have also added TextMode as a property so you can choose between 
> InnerText
> and InnerHTML

Thank you,  I saw the commit but...

>> Currently I'm using a TJSHTMLDivElement and assign its innerHTML.
>> There are other cases where I had to use an html element instead of a 
>> widget since I could find no way to manipulate the content of the widget.
>> Is it so by design or am I doing something wrong?
> Your use of DivHTML (or any other TTagWidget) is correct, but I needed to
> extend the functionality.
> If you feel functionality is missing, don't hesitate to say so, and we'll
> discuss what can be done.

...I still see no way to change the content of a TDivWidget.
Mind me, I don't need more functionality (or better, I don't know what I 
need, this is my first project using pas2js), I just need to learn how 
to best use what's already there.
I can mix and match widgets and elements, but I don't know if that's 
good practice.
I also instinctively prefer to use the widget most close to the tag (I 
just changed a bunch TTagWidget to the real widget type, i.e. TDivWidget 
and TLabelWidget) but maybe that's not good practice either.

> I've used these widgets in multiple projects, but use cases may vary.
> You may want to look at the TSimpleTemplateWidget and TTemplateWidgets if
> you need to set innerHTML a lot, I usually use that.

I'll check those examples, thank you.


More information about the Pas2js mailing list