Hi,
Lets say dynamically user creates html elements and bind it to TWebButton object:
var
Btn:TWebButton;
I:integer;
begin
document.getElementById('list').innerHTML := '';
for I := 0 to 2 do
begin
document.getElementById('list').insertAdjacentHTML('beforeend','<button id="ItemBtn'+IntToStr(I)+'" type="button" class="list-group-item list-group-item-action">A '+IntToStr(I)+' button item</button>');
Btn:=TWebButton.Create('ItemBtn'+IntToStr(I));
Btn.Tag := I;
Btn.OnClick := ItemBtnOnClick;
end;
and that buttons have click event:
procedure TForm1.ItemBtnOnClick(Sender: TObject);
begin
ShowMessage(IntToStr(TWebButton(Sender).Tag)+'. Button');
TriggerBtn.Tag := TWebButton(Sender).Tag;
end;
how can user access dynamically created button element without stored them in data structure?:
procedure TForm1.TriggerBtnClick(Sender: TObject);
begin
TWebButton(document.getElementById('ItemBtn'+IntToStr(TWebButton(Sender).Tag))).Click;
end;
With this lets i have dynamically created button's element id but how to access it through Pascal object? i did create element i did bind it to TWebButton now with binded ID i want to access that TWebButton is that possible?
Yes i did create Pascal class passes html element id.
By this i mean i did create buttons multiple times i dont store them to any arrays, lists, etc... while i create them but i have that dynamically created button's element id.
You can think like findcomponent func where u gave name it will return TComponent
Or
js's document.getElementByID u give id it gives you element
i am asking is there a way to merge these two so when i give ElementID of Pascal Class it will give me TComponent/TWebButton or any other constructor i used. So i can later change its onclick event through Btn.OnClick
If you create Pascal object instances and want to keep using these Pascal object instances, you need to keep a list of these instances you want to keep using (or recreate instances all the time when you want to use these as a way to access the HTML elements)