Why with this code:
{$mode objfpc}
uses
browserapp, JS, Classes, SysUtils, Web, fpjson, fpjsonjs, fprpccodegen;
type
{ TMyApplication }
TMyApplication = class(TBrowserApplication)
edtEmail: TJSHTMLInputElement;
edtPassword : TJSHTMLInputElement;
btnLogin : TJSHTMLButtonElement;
procedure doRun; override;
private
procedure BindElements;
procedure doLoginClick(aEvent: TJSEvent);
procedure doServerLogin(const aUser, aPassword: String);
end;
procedure TMyApplication.doRun;
begin
BindElements;
btnLogin.AddEventListener('click',@DoLoginCLick);
Terminate;
end;
procedure TMyApplication.BindElements;
begin
edtEmail:=TJSHTMLInputElement(GetHTMLElement('edtEmaill'));
edtPassword:=TJSHTMLInputElement(GetHTMLElement('edtPassword'));
btnLogin:=TJSHTMLButtonElement(GetHTMLElement('btnLogin'));
end;
procedure TMyApplication.doLoginClick(aEvent: TJSEvent);
begin
window.alert(edtEmail.value);
DoServerLogin(edtEmail.value,edtPassword.value);
end;
procedure TMyApplication.doServerLogin(const aUser, aPassword: String);
begin
window.alert('Logging in with user: '+aUser);
// to be implemented.
end;
Why does doLoginClick give me the following error? A seems correct.
Uncaught TypeError: this.edtEmail is undefined
doLoginClick client.lpr:50
cb rtl.js:256
DoRun client.lpr:29
Run custapp.pas:206
$main client.lpr:66
run rtl.js:141