Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-11

TCustomWebWidget(DefaultParentElement)

10 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to heliosroots
heliosroots wrote
Maybe you're not using it correctly. When defining "Default ParentElement" for a "Widget" ... when trying to destroy this "Widget", it loses the reference but it remains stuck "DOM" ....

Please explain ?

Maybe the use is not clear:

This is used only for special widgets, such as the viewport/page widgets. They should always be existing DOM elements that must not be freed ?

Michael.

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote
I'm using it for a "modal" dialog ... and at the end of its display, I need to destroy it ... Even if DefaultParenteElement is special when I destroy a widget, it should remove its references, would it be the expectant?

I am not sure that I understand what you mean here.

I often use bootstrap modal dialogs or toasts, and the widgets I use for that have a DefaultParentElement which point to

<div id="modalparent">
<!-- modals are rendered here -->
</div>

and

<div id="toastparent">
<!-- toasts are rendered here -->
</div>

These 2 elements may never be freed ?

Michael.

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote
I understand ... in your case it works like a singleton .... in my case not, because it could have two simultaneous dialogues .... similar to a modal form of lcl

I have multiple toasts open as well ?

<div id="toast-parent">
<div id="toast-1></div>
<div id="toast-2></div>
</div>

And DefaultParentElement,DefaultParent,FixedElement are indeed meant as a singleton.

From what I hear, I think you better simply set ParentID in the constructor

of your widget ?

Michael.

Show quoted text 8 lines
-- Sent from: http://pas2js.38893.n8.nabble.com/ _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote 12 lines
I don't want to create an area to add the dialogues I want them to be in the Body with TMyModal.create(nil) then try // DefaultParentElement =>> document.body ... await(show); finally Free end;

But that should work, this is the exact purpose of DefaultParentElement.

Why does it not work for you ?

Show quoted text 5 lines
|| From what I hear, I think you better simply set ParentID in the constructor || of your widget ? I can't trust the id it changes if it gives a refresh

Not if ParentID is a fixed ID in the HTML.
And as far as I know, you can give an ID to the body element. I would need to check that.

During refresh, we should maybe not regenerate the ID of an element, but reuse the existing one if there is one. I will check this.

Michael.

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote 11 lines
the element reference is stuck in the "DOM". I'm using it as an alternative! destructor TMyDialog.Destroy; begin if (Assigned(Element)) and (Assigned(DefaultParentElement)) then begin DefaultParentElement.removeChild(Element); end; inherited Destroy; end;

Strange, this should not be necessary at all, it should be automatic ?

Hm. I must check this...

Michael.

Reply by email