05-13-2022, 10:11 PM
AddToInitProc() is meant to be used in sync requests, while AddJavaScriptToExecute() is meant to be used in async calls.
If your code needs to be shared between sync/async calls, you can use the TIWControlHelper class:
Just declare IWControlHelper in your uses clause and use the extension method:
procedure AddJavaScriptToExecute(const jsCode: string);
This method will be available in all TIWControl descendants (the TIWControlHelper class is a "real" helper class and follows the same rules as any other helper class in Delphi)
So you can use:
IWBSSelect.AddJavaScriptToExecute('$("#MyIWBSSelect").selectpicker("refresh");');
If your code needs to be shared between sync/async calls, you can use the TIWControlHelper class:
Just declare IWControlHelper in your uses clause and use the extension method:
procedure AddJavaScriptToExecute(const jsCode: string);
This method will be available in all TIWControl descendants (the TIWControlHelper class is a "real" helper class and follows the same rules as any other helper class in Delphi)
So you can use:
IWBSSelect.AddJavaScriptToExecute('$("#MyIWBSSelect").selectpicker("refresh");');