hi all
I'm playing with pas2js reproducing an example found in blaise pascal magazine.
Development environment is Lazarus 2.2.2 + Pas2Js 2.2.0.
Follow some code from attached project:
procedure TMyApplication.doRun;
begin
// Your code here
BindElements;
btnLogin.AddEventListener('click',@DoLoginCLick);
Terminate;
end;
procedure TMyApplication.BindElements;
begin
Writeln('BindElements');
edtEmail:=TJSHTMLInputElement(GetHTMLElement('edtEmail'));
edtPassword:=TJSHTMLInputElement(GetHTMLElement('edtPassword'));
btnLogin:=TJSHTMLButtonElement(GetHTMLElement('btnLogin'));
end;
procedure TMyApplication.doLoginClick(aEvent: TJSEvent);
begin
Writeln('doLoginClick');
// BindElements; // <- uncomment and all works!
writeln('edtEmail.Value = ', edtEmail.value); // <- this give the error
DoServerLogin(edtEmail.Value,edtPassword.Value);
end;
At runtime, if I click on LoginButton I get this error:
project_login.lpr:45 Uncaught TypeError: Cannot read properties of undefined (reading 'value')
at Object.doLoginClick (project_login.lpr:45:40)
at HTMLButtonElement.cb (rtl.js:249:1)
Anyway if I uncomment "// BindElements" from "procedure TMyApplication.doLoginClick(aEvent: TJSEvent)" all works well...
Where I'm wrong?
thanks
nomorelogic