Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AddJavaScriptToExecuteAsCDATA vs AddToInitProc
#5
(05-13-2022, 10:11 PM)Alexandre Machado Wrote: 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");');



Thanks for the explanation, Alexandre!!
But sometimes, only AddToInitProc do the job, while AddJavaScriptToExecute doesn't do nothing.
For instance, when I press a button (ASyncClick) and have many operation, needing to update/refresh several components, when using AddJavaScriptToExecute do update/refresh enabled state of a IWSelect component, it won't work. I have to call AddToInitProc to work as expected.
Reply


Messages In This Thread
RE: AddJavaScriptToExecuteAsCDATA vs AddToInitProc - by Comograma - 05-16-2022, 09:29 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)