In the ajax method Tapestry.Initializer.initAjaxLoader, the event on which trigger.observeAction operates needs to change
Closed this issue · 1 comments
That's the portion I'm talking about:
/**
-
Define JS initializer method for ajaxlaoder component.
-
*/
Tapestry.Initializer.initAjaxLoader = function(params) {/** Observe zone-update */
$(params.zone).observeAction(Tapestry.ZONE_UPDATED_EVENT, function() {
$(params.loader).hide();
});/**
-
Observe trigger process
What used to happen is that when I first click the link, the back end method was called numerous times. Checking the JS console showed a blown stack of recursive calls. Debugging the JS code showed that clicking the link invoked a tapestry method called:
*/
var trigger = $(params.trigger);
if (trigger.tagName == "FORM") {
trigger.observeAction(Tapestry.FORM_PROCESS_SUBMIT_EVENT, function() {
$(params.loader).show();
});
} else if (trigger.tagName == "A") {
trigger.observeAction(Tapestry.ZONE_UPDATED_EVENT, function() {
$(params.loader).show();
});
}
};
Tapestry.waitForPage(event);
-
Which processes the following check:
if (Tapestry.pageLoaded)
return true;
I thought the page isn't loaded yet so this always returns true, which - I suppose - simulates a click on the link, which goes back in the same loop till the stack explodes as the page will never load faster than the JS call ! So I thought to trigger the event after the page is fully loaded. And that's what I have already done in the above code snippet.
Weird... In fact i think observeAction is not the right method to use here. I thought it was a placeholder for prototype observe method, but it seems that i shortcut the elements fire by Tapestry to convert them in ACTION_EVENT...
Finally i have used prototype observe method and it works quite good