[Jifty-commit] r4964 - in jifty/branches/jquery: t/TestApp-JiftyJS/lib/TestApp/JiftyJS

Jifty commits jifty-commit at lists.jifty.org
Wed Jan 30 07:05:33 EST 2008


Author: gugod
Date: Wed Jan 30 07:05:32 2008
New Revision: 4964

Modified:
   jifty/branches/jquery/share/web/static/js/jifty.js
   jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm

Log:
Fix a case where redirection might not work, if current form contains
more then one actions in it. If it worked, it's because the javascript
throws an runtime error and the browser fallback to do a page
refresh, which makes it looks like it's working.  But it's not the
correct behaviour if SinglePage plugin is used.


Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js	Wed Jan 30 07:05:32 2008
@@ -161,7 +161,7 @@
     // Returns an Array of all fields in this Action
     fields: function() {
         if(!this.cached_fields) {
-            var elements = new Array;
+            var elements = [];
             var possible = Form.getElements(this.form);
             // Also pull from extra query parameters
             for (var i = 0, l = this.extras.length; i < l; i++)
@@ -511,7 +511,7 @@
     },
     // Return an Array of Actions that are in this form
     getActions: function (element) {
-        var elements = new Array;
+        var elements = [];
 
         jQuery(":input", element).each(function() {
             if (Form.Element.getType(this) == "registration")
@@ -557,9 +557,9 @@
     getAction: function (element) {
         element = Jifty.$(element);
         var moniker = Form.Element.getMoniker(element);
-        if (!current_actions.moniker)
-            current_actions.moniker = new Action(moniker);
-        return current_actions.moniker;
+        if (!current_actions[moniker])
+            current_actions[moniker] = new Action(moniker);
+        return current_actions[moniker];
     },
 
     // Returns the name of the field
@@ -1102,8 +1102,13 @@
         current_actions[moniker] = a;
         // Special case for Redirect, allow optional, implicit __page
         // from the response to be used.
-        if (a.actionClass == 'Jifty::Action::Redirect')
-            optional_fragments = [ prepare_element_for_update({'mode':'Replace','args':{},'region':'__page','path': a.fields().last().value}) ];
+        if (a.actionClass == 'Jifty::Action::Redirect') {
+            (function() {
+                var fields = a.fields();
+                var path = fields[fields.length - 1];
+                optional_fragments = [ prepare_element_for_update({'mode':'Replace','args':{},'region':'__page','path': path}) ];
+            })()
+        }
         a.result = {};
         a.result.field_error = {};
 

Modified: jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
==============================================================================
--- jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	(original)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	Wed Jan 30 07:05:32 2008
@@ -218,7 +218,7 @@
 };
 
 template '/act/play2' => page {
-    my $action = new_action(class => 'Play2');
+    my $action = new_action(class => 'Play2', moniker => "play2");
     form {
         render_action($action);
         form_next_page( url => "/redirected");


More information about the Jifty-commit mailing list