[Lazarus] Pas2Js and component binding
Michael Van Canneyt
michael at freepascal.org
Tue May 24 09:30:49 CEST 2022
On Tue, 24 May 2022, Marcello via lazarus wrote:
>
> hi all
>
> I've some problems in binding html elements.
>
> This is the thread I open in forum, attached you can found the my source project.
> https://forum.lazarus.freepascal.org/index.php/topic,59432.0.html
>
> The strange is: inside doRun I call BindElements and seems it works.
> Inside the OnClick event of a button, the bind is not valid anymore and I need to bind again before using components.
>
> 1. procedure TMyApplication.doLoginClick(aEvent: TJSEvent);
> 2. begin
> 3. Writeln('doLoginClick');
> 4. // BindElements; // <- uncomment and all works!
> 5. writeln('edtEmail.Value = ', edtEmail.value); // <- this give the error
> 6. DoServerLogin(edtEmail.Value,edtPassword.Value);
> 7. end;
>
> So, why the bind is not persistent and I need to bind again before use a component in OnClick event?
> Any idea?
Normally the bind should be persistent.
I use the described technique since several years meanwhile.
Please check if your program code contains an Application.Free after the Application.Run.
If it does, remove it.
Earlier versions of Lazarus generated this statement erroneously when using
the 'new web application' wizard.
I've been bitten by that problem myself several times.
Michael.
More information about the lazarus
mailing list