[Pas2js] How to change a div (or othe widget) content
Michael Van Canneyt
michael at freepascal.org
Mon Oct 3 17:35:27 CEST 2022
On Mon, 3 Oct 2022, Luca Olivetti via Pas2js wrote:
> I have a div in my html and I want to change its content. For consistency,
> I'd like to use a TDivWidget, but I could find no way to modify the content:
> I cannot manipulate the TDivWidget itself and creating a TLabelWidget and
> assigning the TDivWidget as its parent does nothing.
> 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
> 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'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.
More information about the Pas2js