For example, you can listen to Tapestry.FORM_PROCESS_SUBMIT_EVENT to show the
div over the form, and then listen to Tapestry.ZONE_UPDATED_EVENT (this is
fired when you update the content of a Zone).

In order to put an overlay in all Zones, either associated with forms or
with links, you can observe this two events:

document.observe(Tapestry.FORM_PROCESS_SUBMIT_EVENT, function(event) {
        var form = event.findElement();
        var zoneManager = Tapestry.findZoneManager(form);
        K12.showLoading(zoneManager.element);
});

document.observe(Tapestry.TRIGGER_ZONE_UPDATE_EVENT, function(event) {
        var zone = event.findElement();
        K12.showLoading(zone.element);
});

Where K12.showLoading() creates or shows this overlay.

To remove the overlay, in most cases you can use the
Tapestry.ZONE_UPDATED_EVENT event, but this doesn't work well if your event
response from the server uses a MultiZoneUpdate (because this will trigger
Tapestry.ZONE_UPDATED_EVENT on every updated Zone and maybe that doesn't
include the Zone associated with the initial update trigger). So, what I did
was to decorate the method where the requesting Zone process the reply:

(function() {
        Tapestry.ZoneManager.addMethods({
                processReply:
Tapestry.ZoneManager.prototype.processReply.wrap(function(proceed, reply){
                        proceed(reply);
                        K12.hideLoading(this.element);
                })
        });
})();

in K12.hideLoading() I hide (or remove if you want to) the created overlay
(which is stored in a property inside the Tapestry object of the element (
$T(element) ) ).

I didn't like it too much to decorate this method, but it was the better way
I found. If anybody has a better way, please share :)

Regards,
Raul.
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/T5-Prevent-multiple-form-submits-tp5477609p5484015.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to