Re: Showing and hiding an overlay during an ajax call

"Esteban A. Maringolo" <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <CAJMgPCK43AGpLQ-cTmZ1dHEKefo0YCdPahsVSRBFcVgPTuxV+A@mail.gmail.com>
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 <[email protected]>:
> 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
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.