I've tried twice before to post my solution on this, but here's a third try:
So I solved this for my app, in the following way. For reference for
others, and for comment if I'm doing something stupid. But, this works for
me:
In my view:
{{=LOAD('tenant','stackList.load',ajax=True, target="stackList",vars={
'reload_div':'stackList'},content=CENTER(IMG(_src=URL(request.application,
'static','images/ajax_loader_blue_256.gif'))))}}
I'm using my 'tenant' 'stackList' controller. This content= tag, handles
the AJAX preload spinner upon page load. When the component is told to
refresh, using (in another controller):
spinner=CENTER(IMG(_src=URL(request.application,'static',
'images/ajax_loader_blue_256.gif')))
response.js =
"jQuery('#stackList').html('{0}');jQuery('#stackList').get(0).reload()".
format(spinner)
I define my image to use, and then my response has two jQuery calls, the
first replaces my #stackList div with the spinner image, and the second
calls the ajax reload.
So when I click the refresh action on the page, the div is replaced
immedialey with a preload spinner, and then some seconds later, the data
appears. It would look more elegant perhaps if I were to fade out the div
instead. I don't know, but if you can do it with jQuery, you could do it
like this.
Actually I think my solution ended up being much simpler than almost any
example of this I've seen so perhaps it can help some people.
On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:
>
> Hello
>
> I have a DIV component I'm reloading using another controller , so I end
> up calling:
>
> response.js = "jQuery('#stackList').get(0).reload()"
>
> Problem is, my stackList controller function does a lot of work to rebuild
> the grid, it makes many AWS api calls, to populate the grid.
>
> The reload works, and the grid eventually updates, but there is no
> indication that it's doing anything, it has the old values for ages (well,
> 10 seconds or so, seems like ages) after the other form is submitted then
> it snaps to its new output.
>
> How can I make the div update immediately with a spinning 'progress' , or
> maybe fade it out at the start of the refresh, and in at the end? Anything
> to provide a visual clue that the controller function is running, and that
> the display is stale
>
> Thanks
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.