I have a JS code (asm bloc) with a grid with a button in each row
I have get for each the same class attribute "SEEOFFER"
And after in pascal code I have this code :
aElementList := document.querySelectorAll('SEEOFFER');
aElementList.forEach(............);
I would like to know what is the instruction inside forEach
to call this pascal function
procedure THomeForm.showOffer(Event: TJSMouseEvent);
begin
end;
Is your ASM block within the scope of the THomeForm?
If so, using this.showOffer() should work.
Look at my question showOffer() is defined in my unit like this
procedure THomeForm.showOffer(Event: TJSMouseEvent);
begin
.....
end;
I have this :
procedure THomeForm.INitSmartGrid();
begin
.....
asm
....
end;
// --- call Pascal function
aElementList := document.querySelectorAll('SEEOFFER');
aElementList.forEach('click',this.showOffer());
end;
this doesn't work.
try
procedure THomeForm.INitSmartGrid();
procedure callproc(event: TJSMouseEvent);
begin
self.showOffer(event);
end;
begin
.....
asm
....
end;
// --- call Pascal function
aElementList := document.querySelectorAll('SEEOFFER');
aElementList.forEach('click',callproc);
end;
Good Idea but still parameters call is not respected.
Compilation error :
"message": "Wrong number of parameters specified for call to "OpenOffer"",
try
aElementList.forEach('click',@callproc);
Compilation error :
"message": "Incompatible type for arg no. 1: Got "String", expected "TJSNodeListEvent"",
Well, I cannot see how you can use forEach the way you want to use it:
When you use it like it is supposed to be used, this compiles & works in TMS WEB Core:
var
aElementList: TJSNodeList;
procedure callproc(node: TJSNode; index: NativeInt; list: TJSNodeList);
begin
console.log('test');
end;
begin
aElementList := document.querySelectorAll('SEEOFFER');
aElementList.forEach(@callproc);
end;
It's a little bit complicated.
To explain here !
I use a new approach I use eventlistener on smart-grid and I test if is the smart-button the target of clic-event.
You can close this
Just a little remark for VS version can you stop the opening of browser if the compilation get an error ?