[jifty-devel] Suggested API change for clickables/onclick handlers

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Wed Oct 10 23:24:04 EDT 2007


On 10/10/07, Jesse Vincent <jesse at bestpractical.com> wrote:
>
> So. I want the behaviour as you describe. But I thought we already had it.
>

If we do, I haven't found it. I know how to fake it on true submits, but not
via JavaScript handlers and I'd rather not fake it. To be honest, I was
surprised that such a thing wasn't there myself. I'm know that the request
mapper can do all the work, but I haven't yet found the tools in the form
elements to set it up for me.

There's quite a bit of cross-dependencies between J::W::F::Element, ::Field,
::Clickable, and ::Field::* so that I still don't have a very certain handle
on that piece of Jifty's guts (not to mention Jifty::Web, Jifty::Web::Form,
Jifty::Action, etc., etc.). I'm still trying to get a better handle on these
things.

This is currently important to a toy project, so I haven't actually worked
toward a patch just yet due to lack of time. I'd certainly be glad if
someone knows of it already being there and I've just missed it.

Cheers,
Andrew

-jesse
>
> On Oct 8, 2007, at 8:07 PM, Andrew Sterling Hanenkamp wrote:
>
>
> Second, I'd like to propose adding to the API a way of submitting
> additional action parameters on the button. It should be pretty easy to add
> since Jifty already handles the "parameters" bit here without much of a
> problem. My proposal is to add a new accessor to
> Jifty::Web::Form::Clickable: "submit_args" that could be used like this:
>
> $action->button(
>     label => _('Submit'),
>     submit => $action,
>     submit_args => [ $action => { submit => 1 } ],
> ) ;
>
> As you can see I've now provided by Submit button without exposing Jifty's
> "J:A:F" parameter nomenclature. The "submit_args" would be an array ref
> where the even indexes are the names of the actions or monikers being
> submitted and the odd indexes are a hash of arguments to add. As a shortcut,
> it would be possible to drop "submit" in cases where "submit_args" is used:
>
>
> $action->button(
>     label => _('Submit'),
>     submit_args => [ $action => { submit => 1 } ],
> );
>
> Similarly, the "onclick" and related handlers of Jifty::Web::Form::Element
> should be modified to match, so that I could then perform:
>
> $action->button(
>     label => _('Submit'),
>     onclick => {
>         submit_args => [ $action => { submit => 1 } ],
>     },
> );
>
> This would then perform the same action as above but allow me to use a
> JavaScript handler to perform the submit with arguments rather than a
> regular form post.
>
> In addtion to allowing two buttons to have different behaviors on the same
> action, this would allow for hidden parameters without having to add a
> separate input to the form. I see a potential here for more advanced
> link-based action submissions as well.
>
>
>
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20071010/0ede9164/attachment.htm


More information about the jifty-devel mailing list