Jump to content

Client Event ajaxRequest Synchronous ?


mterceno

Recommended Posts

Hi all,

Is it possible to synchronously call a similar function "ajaxRequest" ? 

For example, if a TuniForm has a few TUniEdit, I would like that when enter(focus) in second (event), the client call the server method via ajaxRequest() and the client stays waiting as long as the call of ajaxRequest is not terminated. In this case f.e., impossible to press tab to focus in next TUniEdit.

Do you think that possible ?

Thank you

Link to comment
Share on other sites

Hello (mterceno co-worker here ;-) )

It seems that adding the "false" parameter to the ajaxRequest method ensure that the code in OnAjaxEvent() is executed before any other client-side request.
But the problem is that all CS requests made during the process (mouse clics, keyboard inputs, ... queued I guess) are still executed after the OnAjaxEvent() code is done.
How could we stop the UI from catching all events during OnAjaxEvent() execution?

I tried this approach (using a mask) to no avail (simple test with a button click):

JS:

function click(sender, e, eOpts)
{
   MainForm.form.showMask();
   ajaxRequest(sender, 'myclickevent', [], false);  
}

Delphi:

procedure TPurchaseEntriesFrame.UniButtonTestAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  inherited;
  if EventName = 'myclickevent' then
  try
    UniLabel7.Caption := UniLabel7.Caption + ' myclickevent';
    Sleep(1000);
  finally
    UniSession.AddJS('MainForm.form.hideMask();');
  end;
end;

For example, if the user clicks on the button again while UniButtonTestAjaxEvent() is performed, the second click event is still catched and fired after. (mask is not shown)

 

Link to comment
Share on other sites

PS:

I know I could just remove the "false" parameter from ajaxRequest() but this doesn't work 100% of the time (I tried with grid operations like deleting a record from a button).
If the user clicks two times super-fast some problems occurs (code is executed twice but UI is not refreshed etc.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...