On 10/10/07, <b class="gmail_sendername">Jesse Vincent</b> &lt;<a href="mailto:jesse@bestpractical.com">jesse@bestpractical.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="">
<div>So. I want the behaviour as you describe. But I thought we already had it.</div></div></blockquote><div><br>If we do, I haven&#39;t found it. I know how to fake it on true submits, but not via JavaScript handlers and I&#39;d rather not fake it. To be honest, I was surprised that such a thing wasn&#39;t there myself. I&#39;m know that the request mapper can do all the work, but I haven&#39;t yet found the tools in the form elements to set it up for me. 
<br><br>There&#39;s quite a bit of cross-dependencies between J::W::F::Element, ::Field, ::Clickable, and ::Field::* so that I still don&#39;t have a very certain handle on that piece of Jifty&#39;s guts (not to mention Jifty::Web, Jifty::Web::Form, Jifty::Action, etc., etc.). I&#39;m still trying to get a better handle on these things.
<br><br>This is currently important to a toy project, so I haven&#39;t actually worked toward a patch just yet due to lack of time. I&#39;d certainly be glad if someone knows of it already being there and I&#39;ve just missed it.
<br><br>Cheers,<br>Andrew<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style=""><span class="sg"><div>-jesse</div></span>
<span class="q"><br><div><div>On Oct 8, 2007, at 8:07 PM, Andrew Sterling Hanenkamp wrote:</div><br><blockquote type="cite"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Calibri; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<br>Second, I&#39;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 &quot;parameters&quot; bit here without much of a problem. My proposal is to add a new accessor to Jifty::Web::Form::Clickable: &quot;submit_args&quot; that could be used like this:
<span>&nbsp;</span><br><br><span style="font-family: courier new,monospace;">$action-&gt;button(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; label =&gt; _(&#39;Submit&#39;),
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; submit =&gt; $action,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp; submit_args =&gt; [ $action =&gt; { submit =&gt; 1 } ],</span><span style="font-family: courier new,monospace;"></span><br>)<span style="font-family: courier new,monospace;"><span>&nbsp;</span>;<br><br></span>As you can see I&#39;ve now provided by Submit button without exposing Jifty&#39;s &quot;J:A:F&quot; parameter nomenclature. The &quot;submit_args&quot; 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 &quot;submit&quot; in cases where &quot;submit_args&quot; is used:
<span>&nbsp;</span><br><br><span style="font-family: courier new,monospace;">$action-&gt;button(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; label =&gt; _(&#39;Submit&#39;),
</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; submit_args =&gt; [ $action =&gt; { submit =&gt; 1 } ],
</span><span style="font-family: courier new,monospace;"></span><br>)<span style="font-family: courier new,monospace;">;</span><br><br>Similarly, the &quot;onclick&quot; and related handlers of Jifty::Web::Form::Element should be modified to match, so that I could then perform:
<br><br><span style="font-family: courier new,monospace;">$action-&gt;button(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; label =&gt; _(&#39;Submit&#39;),</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; onclick =&gt; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit_args =&gt; [ $action =&gt; { submit =&gt; 1 } ],</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; },</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">);</span><br><br>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.
<span>&nbsp;</span><br><br>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.
<span>&nbsp;</span><br></span></blockquote></div><br></span></div><br>_______________________________________________<br>jifty-devel mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:jifty-devel@lists.jifty.org">
jifty-devel@lists.jifty.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
</a><br><br><br clear="all"></blockquote></div><br>