Hi all,
I have a problem on addEventlistener on hidden div
I have a form with 2 TWebHTMLDiv (VisiDiv & HidDiv)
VisiDiv is visible and HidDiv not.
In the create form proc I define each div contents
// --- first visible
VisiDiv.HTML.Add ('
.....
VisiDiv.HTML.Add('Login'); // _buttonloginid is a const
VisiDiv.HTML.Add ('
// --- second not visible
HidDiv.HTML.Add ('
.....
HidDiv.HTML.add(' Rechercher'); // _buttonsearchid is a const
HidDiv.HTML.Add ('
// --- Add events
aElement1 := document.getElementById(_buttonloginid);
if (aElement1 <> null) then aElement1.addEventListener('click',@Self.loginClick);
aElement2 := document.getElementById(_buttonsearchid);
if (aElement2 <> null) then aElement2.addEventListener('click',@Self.searchClick);
I tried many possible combinations but event2 of aElement2 (searchClick) is never fire.
Only when div2 (HidDiv) is visible from start.
The only way is to add a proc on "TWebHTMLDiv.onclick" (HidDiv_MouseClick(Sender: TObject);) directly on "HidDiv component" () and after use this in function
procedure TMainForm.HidDiv_MouseClick(Sender: TObject);
var
aInput,
aElement : TJSElement;
aSearchText : String;
begin
// Init
asm
aElement = event.target;
end;
if (aElement.id = _buttonsearchid) then
begin
end;
end;
Is there no other way ???
It means that we can't add a listener on element of an hidden TWebHTMLDiv ???
Thanks