I'm using a TWebResponsiveGrid and Add'ing raw html using data I get from an http request.
Each item needs to have two buttons, which need to trigger Pascal functions, but I can't figure out how to do that.
I'm using a TWebResponsiveGrid and Add'ing raw html using data I get from an http request.
Each item needs to have two buttons, which need to trigger Pascal functions, but I can't figure out how to do that.
In case anyone else runs into this, it turned out to be pretty simple.
For the dynamically inserted item:
WebResponsiveGrid1.Items.Add('Task: ' + JO.GetJSONValue('task') + '<input data-id="' + JO.GetJSONValue('_id') + '" id="btn_' + JO.GetJSONValue('_id') + '" type="button" class="clicker" value="Done"></input>');
el := document.getElementById('btn_' + JO.GetJSONValue('_id'));
el.addEventListener('click',@MarkDoneClick);
And for the procedure
procedure TForm1.MarkDoneClick(Event: TJSEvent);
begin
ShowMessage('Item id: ' + Event.target.getAttribute('data-id'));
end;
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.