In runtime, I create HTML code and insert it to TWebHtmlDIV. Bootstrap accordion + list-group + buttons. How I can attach events (click) in this code to methods in Delphi?
i try next code in html page
<button class="btn btn-primary round" type="submit" id="TestButton" onclick="this.TestProc(2)">Search</button>
in form code
procedure TFormBrandList.TestProc(i: integer);
begin
Showmessage(i.ToString);
end;
and got error, but if i add next code on create form all works fine
procedure TFormBrandList.WebFormCreate(Sender: TObject);
begin
asm
var ele = document.getElementById('TestButton');
ele.onclick = (e) => {this.TestProc(1) };
end;
end;
what am I doing wrong? i want to setup onclick event right in html code
onclick="this.TestProc(2)"
"this" in that context refers to the button.
Assuming your unit name is FormBrandListUnit and form name is FormBrandList you can call it like this:
<button type="submit" id="TestButton" onclick="pas.FormBrandListUnit.FormBrandList.TestProc(2)">Search</button>
Hmm.... not working
Can you upload a simple project?
if you adjust unit name and form variable name to match with your project should work. I tested here before my reply.