[Seaside] Showing and hiding an overlay during an ajax call

Esteban A. Maringolo emaringolo at gmail.com
Mon Jul 10 17:12:36 UTC 2017


Hi Dave,

You shouldn't do a "addLoadScript:" but rather a simple script.

ej:

html anchor
  url: 'javascript:void()';
  onClick: (html jQuery script: [:s |
                    s <<  (JSStream on: '$.LoadingOverlay("show");').
                    s << html jQuery ajax
                               callback: [ "long server operation" ];
                               onSuccess: (JSStream on:
'$.LoadingOverlay("hide")')
                  ] );
  with: 'Click me to run lenghty server operation'


addLoadScript: is used document-wide, and mostly at the initial page
load, so it isn't suitable to be used as a script (it is, a javascript
anonymous function) you pass to be used as a handler or callback.

Hope it helps.



Esteban A. Maringolo


2017-07-10 13:45 GMT-03:00 Dave <lasmiste at gmail.com>:
> Hi guys,
>
> I want to show and dismiss an overlay
> (https://gasparesganga.com/labs/jquery-loading-overlay/) during an quite
> long processing that starts from an ajax call.
> Showing the overlay is not an issue, but I can't dismiss it.
>
>
> My code is:
>
>
> html document addLoadScript: (JSStream on: '$.LoadingOverlay("show");').
>
> html jQuery ajax
>                 callback: [ ... ] value: (JSStream on: '...');
>                 onSuccess:
>                         ((html jQuery id: 'myId') load
>                                 html: [ :h | self veryLongOperationOn: h ]).
>
>
> Now I don't know where to put the code to hide the overlay. If I write:
>
> html jQuery ajax
>                 callback: [ ... ] value: (JSStream on: '...');
>                 onSuccess:
>                         ((html jQuery id: 'myId') load
>                                 html: [ :h | self veryLongOperationOn: h ]);
>                 *onComplete: (html document addLoadScript: (JSStream on:
> '$.LoadingOverlay("hide");'))*
>
> The overlay immediately disappears because the onComplete does not wait for
> the veryLongOperation. So I think I should put the code in the block like:
>
> html jQuery ajax
>                 callback: [ ... ] value: (JSStream on: '...');
>                 onSuccess:
>                         ((html jQuery id: 'myId') load
>                                 html: [ :h | self veryLongOperationOn: h.
>                                 *h document addLoadScript: (JSStream on: '$.LoadingOverlay("hide");')*
> ])
>
> but of course it does not work.
>
> Can you help me please?
> TIA
> Dave
>
>
>
> --
> View this message in context: http://forum.world.st/Showing-and-hiding-an-overlay-during-an-ajax-call-tp4954136.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list