If you have a pages that is slow to load like a search, its best to have some sort of small animation (small spinner or _ underscore blink) whist the pages starts loading. So the user knows somethings is happening.
It needs to start at the point of someone submitting a form.
It’s done on the forum by using the Ajax design pattern and the Prototype JavaScript framework.
If you don’t want to make a refresh-less (Ajax) form, but you want to keep people from pressing the button twice or similar, you can do this:
Apply the Protaculous Action to the page.
Download the image: http://freewaytalk.net/Resources/spinner.gif and make sure it gets published to your Resources folder. (Put it in the corner of a scratch page, or use the Upload Stuff or Extra Resources Actions to put it where you can find it later.)
Make sure your submit button has an ID (you’ll need to use the Extended dialog to add one), and also make sure that you are not using the submit button as part of your form handler. If you are using Tim Plumb’s PHP Feedback Form Action – this means you, sadly.
In the first Function Body button in the Protaculous Action, add the following:
JavaScript:
var b = $('YourSubmitButtonID');
var f = b.up('form');
f.observe('submit',function(evt){
b.wrap('div').update('<img src="Resources/spinner.gif" width="16" height="16" alt="" />');
return f.submit();
});
This will replace the button with the spinner as soon as it is clicked, and then submit the form. Depending on how quickly your server responds to that submission, your spinner might not be on screen all that long.
One of two things is happening here. Either the form call is
returning too fast for the replacement to take place (which the
evt.stop() will handle), or the browser is not liking the idea of
using replace in this manner.
Walter
On Jun 9, 2008, at 12:29 PM, WebWorker wrote:
Sorry spoke too soon. Works in Freeway Preview. But not in a
browser.
In Safari, no spinning image, In Firefox, just a broken link image
(But the URL is correct)
I added a 50 millisecond timer into it to give the image time to load and display when the connection is faster. The final function reads like this:
var b = $('YourSubmitButtonID');
var f = b.up('form');
var s = function(){ return f.submit(); };
f.observe('submit',function(evt){
evt.stop();
b.replace('<img src="Resources/spinner.gif" width="16" height="16" alt="" />');
window.setTimeout(s,50);
});