hlship / tapx

Extensions to Tapestry 5
http://tapestry.formos.com/projects/tapx/
29 stars 7 forks source link

Confirm never updates page in FF #31

Open joostschouten opened 13 years ago

joostschouten commented 13 years ago

In firefox the confirm works good on ajax updates but not if the underlying link updates the whole page. Chrome works well. This is due to the following (see arrows):

function doAction() {
            if ($T(element).hasAction) {
                element.fire(Tapestry.ACTION_EVENT, capturedClickEvent);
                return;
            }

            /*
             * Is it a submit element (i.e., it has a click() method)? Try that
             * next.
             */

            if (element.click) {
                interceptClickEvent = false;

                element.click();
                return;             <--------!! This return prevents the window.location = element.href; from being reached !!
            }

            /*
             * Not a zone update, so just do a full page refresh to the
             * indicated URL.
             */
            window.location = element.href;
    }

Any reason why the return is there? Without it all seems to work for me.

This patch did the trick for me:

From b7854105325f4d9078aaa8e5ca9de35a617aafa3 Mon Sep 17 00:00:00 2001
From: Joost Schouten <***@jsportal.com>
Date: Thu, 28 Jul 2011 12:33:11 +0200
Subject: [PATCH] bugfix: removed the return statement from the doAction which was preventing a full page refresh in FF4

---
 .../com/howardlewisship/tapx/core/tapx.js          |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx.js b/tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx.js
index d036984..4a11465 100644
--- a/tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx.js
+++ b/tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx.js
@@ -373,7 +373,6 @@ Tapx.extendInitializer(function() {
                interceptClickEvent = false;

                element.click();
-               return;
            }

            /*
-- 
1.6.4.1
hlship commented 13 years ago

I thought I had manually tested that. The return is there because the element.click() call is expected to re-invoke this method (as the listener for the click event) and on the second pass drop down to window.location assignment. I'll recheck if this works for me ... I probably was testing in Chrome. If you remove the "return" statement, I believe it will break the Ajax use case. Sometimes I hate HTML.

joostschouten commented 13 years ago

I had the problem with FF5.0.1. Without the return my usecases work for ajax and non ajax in FF5, chrome, IE7,8,9. But now you mention it, I did seem to have a problem in IE i needed to investigate where sometimes I got exceptions indicating I was deleting an already deleted item (confirm on delete). Which could indicate a double call which might be related to the second invocation not quite working as it should without the return. I'll dive into it a bit more. Looking forward to hearing your findings as well. And I agree, cross browser stuff is not my favorite activity ;-)