There is a loading gif already built into web2py.
Look at the parameters of the LOAD function it was added almost a year ago.
On 1/9/12 1:58 PM, Liam wrote:
Hi all,
I'm currently writing a plugin for part of a bigger project that can
take some time doing processing server side and I'm trying to make it
as modular as possible; thus the plugins and components. The problem
I'm trying to solve is this: The application uses LOAD to embed some
html generated by the plugin in the page. A link in the LOADed html
will start some analyses and will be replaced by an image of a loading
gif while waiting for the analyses to complete and the html to be
returned.
I've been trying to return javascript with the html from the plugin
that activates when the link is clicked without any success. I don't
even know if the javascript will be applied to the link in the html
that it is returned with. I've tried a few approaches:
1. Script elements seem to disappear if placed inside the view/controller.
2. response.files.append(...) doesn't add a js script to the outer
page's files.
3. _onclick="..." in the A helper gets overwritted by the
web2py_component function that allows the plugin html and responses to
be loaded inside the page
I've done a day's digging, but turned up nothing.
4. I've also tried setting response.js in the component controller,
but I'm having trouble debugging this because nothing turns up in FireBug.
Does someone have any ideas? It doesn't need to deal directly with
javascript, but it does need to be a component plugin.
Cheers,
Liam