SIRE Software Posted March 24, 2021 Share Posted March 24, 2021 Good afternoon! In my application i have a button that in the click event does some stuff but at the end of the event i need to call a javascript function and pass it a string as a parameter, the function will be implemented in a file that i will load in the ServerModule's custom files property? how could i do that?? thanks in advance! Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Share Posted March 25, 2021 4 hours ago, Victor Dominguez said: Good afternoon! In my application i have a button that in the click event does some stuff but at the end of the event i need to call a javascript function and pass it a string as a parameter, the function will be implemented in a file that i will load in the ServerModule's custom files property? how could i do that?? thanks in advance! Hi, I use this to start every javascript commands from file or direct command execute: procedure JAVASCRIPT_EXEC (Sender: TObject; fType, Data, DataObjectsList : AnsiString); var I : Integer; DataList : TStringList; sObject : TObject; begin if (Sender <> nil) then begin TRY With TUniControl (Sender) do begin ScreenMask.Message := 'Please, wait ...'; ScreenMask.WaitData := False;//True; ScreenMask.Enabled := False;//True; end; EXCEPT END; end; IF (Length (Data) > 1) then begin DataList := TStringList.Create; DataList.StrictDelimiter := True; DataList.Delimiter := ';'; //read data from file if file exists If FileExists (Data) then begin DataList.LoadFromFile (Data); Data := TRIM (DataList.Text); DataList.Clear; //DataList.Free; //If Assigned(DataList) then // FreeandNil (DataList); end; end; //TUnibutton (Sender).ClientEvents.ExtEvents.Values ['click'] := 'function click(sender, e, eOpts){' + Data + '}'; //UniSession.JSCode (Data); UniSession.AddJs (Data); //UniSession.JSONDirect (Data); end; This function I can start from every component 1 Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Share Posted March 25, 2021 Other solution for Your needs: //load custom file javascript function if (FileExists (ExtractFilepath (Application.ExeName) + '\files\voicescript.js')) then CustomFiles.Add ('files/voicescript.js'); //use function unisession.AddJS('youfunctionname (functionparameters)' ); 1 Quote Link to comment Share on other sites More sharing options...
SIRE Software Posted March 25, 2021 Author Share Posted March 25, 2021 9 hours ago, irigsoft said: Other solution for Your needs: //load custom file javascript function if (FileExists (ExtractFilepath (Application.ExeName) + '\files\voicescript.js')) then CustomFiles.Add ('files/voicescript.js'); //use function unisession.AddJS('youfunctionname (functionparameters)' ); Thank you so much! This is so helpful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.