[Seaside] show spinner until something is done
Sabine Manaa
manaa.sabine at gmail.com
Mon Jul 25 09:52:38 UTC 2016
I create pdf reports which are converted to pngs for small previews (and
print/mail/export).
When the user clicks at "report", there are several pdf reports and their
pngs generated in the background.
In this moment (When the user clicks at "report"), the application changes
to the reports page.
But in this moment, the repots possibly are not yet finished :-)
So, I want to show a spinner/counter for each of the reports and update
each in the moment when the png is ready.
I succeeded with all but the spinner/counter and the moment when the page
renders. Its to late.
My problem is that the page is rendered only in the moment, when the code is
run. Not earlier.
I assume the onLoad is to late? I tried several things for several hours :-(
and now I want to ask the community.
I reduced the problem to a very simple example: 2 methods with the question:
how to change this code to update the counter 1,2,3,4...
Very curious about a solution
>>renderContentOn: html
html div
id: 'image';
with: [ html text: 'Waiting for the report' ].
html div
id: 'counter';
with: [ html text: 'This should count 1,2,3...' ].
html document addLoadScript: (html jQuery ajax script: [ :script | self
loadScriptIndex: 1 script: script ])
>>loadScriptIndex: anIndex script: s
| theIndex |
(Delay forMilliseconds: 100) wait.
theIndex := anIndex.
"aPngFilename asFileReference exists" anIndex > 50 "simulate file is there
after some time"
ifTrue: [
s << (s jQuery: #image)
replaceWith: [ :h |
h text: theIndex asString.
h image
altText: 'Report';
width: '100%';
url: 'http://localhost/reports/a.png' ] ]
ifFalse: [ theIndex := theIndex + 1.
s << (s jQuery: #counter)
replaceWith: [ :h |
h div
id: #counter;
with: [ h text: theIndex asString ] ].
self
loadScriptIndex: theIndex
script: s
and possibly
registerTestApplication
| theApplication |
theApplication := WAAdmin register: RKATestView asApplicationAt: 'RKT'.
theApplication
addLibrary: JQDeploymentLibrary;
addLibrary: JQUiDeploymentLibrary.
^ theApplication
--
View this message in context: http://forum.world.st/show-spinner-until-something-is-done-tp4907725.html
Sent from the Seaside General mailing list archive at Nabble.com.
More information about the seaside
mailing list