What could be the reasons why an onclick event isn't triggered?
I have two buttons. One was created at design time and the other at runtime.
In the browser (debug), I only see an event for the first one.
The code is very simple
constructor TMyListItem.Create( AHTMLIndex: Integer);
begin
inherited Create;
FHTMLIndex := AHTMLIndex;
FButtonDel := TWebButton.Create( 'MyElementID' + FHTMLIndex.ToString);
FButtonDel.ElementClassName := '';
FButtonDel.OnClick := ButtonDelOnClick;
end;
procedure TMyListItem.ButtonDelOnClick( Sender: TObject);
begin
console.log( Sender);
end;
I don't have a parent. But even with the form as the parent, it didn't work.
FButtonDel.Parent := AOwner; // AOwner = TheForm
Is it perhaps a timing problem?
Is there anything else that needs to be done when elements (with events) are created at runtime?