[Jifty-commit] r3360 - jifty/trunk/lib/Jifty/Web

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jun 5 15:42:59 EDT 2007


Author: clkao
Date: Tue Jun  5 15:42:28 2007
New Revision: 3360

Modified:
   jifty/trunk/lib/Jifty/Web/Form.pm

Log:
SinglePage submit hack.

Modified: jifty/trunk/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form.pm	Tue Jun  5 15:42:28 2007
@@ -217,8 +217,19 @@
 
 sub submit {
     my $self = shift;
-
-    my $button = Jifty::Web::Form::Clickable->new(submit => undef, @_)->generate;
+    my %args = ( submit => undef, @_ );
+    my ($spa) = Jifty->find_plugin('Jifty::Plugin::SinglePage');
+    if ($spa) {
+	# XXX: merge with _sp_link hook.
+	if ($args{onclick}) {
+	    Carp::cluck "already has onclick, fix me later";
+	}
+	else {
+	    my $submit = delete $args{submit} || [undef]; # something special for js to handle
+	    $args{onclick} = {submit => $submit, refresh_self => 1};
+	}
+    }
+    my $button = Jifty::Web::Form::Clickable->new(%args)->generate;
     Jifty->web->out(qq{<div class="submit_button">});
     $button->render_widget;
     Jifty->web->out(qq{</div>});


More information about the Jifty-commit mailing list