Sorry I think the syntax would be (I haven't tested it though):

 <button onclick={((JqId("hidden_field_id") >> JqAttr("value", "add"))
& SHtml.submitAjaxForm(form_ID)).toJsCmd}>add</button>
 <button onclick={((JqId("hidden_field_id") >> JqAttr("value",
"edit")) & SHtml.submitAjaxForm(form_ID)).toJsCmd}>edit</button>
 <button onclick={((JqId("hidden_field_id") >> JqAttr("value",
"delete")) & SHtml.submitAjaxForm(form_ID)).toJsCmd}>delete</button>

Br's,
Marius

On Jan 10, 6:58 pm, Marius <marius.dan...@gmail.com> wrote:
> On Jan 10, 5:20 pm, Adam Warski <a...@warski.org> wrote:
>
> > Hello,
>
> > > ajaxButton("Press me would ya'?", SHtml.submitAjaxForm
> > > (form_ID).toJsCmd, (some) => {
>
> > > do your stuff here
>
> > > })
>
> > Looking at the source code I think this might work, but I'm having trouble 
> > constructing the correct expression to pass to ajaxButton. The method 
> > signature requires a Call instance, and SHtml.submitAjaxForm results in a 
> > command (JsCmd). Is it possible to somehow combine the two?
>
> I was referring to this signature:
>
> def ajaxButton(text: NodeSeq, jsExp: JsExp, func: String => JsCmd,
> attrs: (String, String)*): Elem
>
> and not
>
> def ajaxButton(text: NodeSeq, jsFunc: Call, func: () => JsCmd, attrs:
> (String, String)*): Elem
>
> jsExp will be called before sending the actual ajax. But this may be a
> bit problematic if your jsExp sends the ajaxForm the ajax request is
> processed asynchronously at js level meaning the the button ajax
> request may be send before the actual ajax form processing is done.
> I'm not sure if this fits your needs
>
>
>
> > Or maybe there is some other, lift-idomatic way to solve my problem?
> > I want to create a form with a list of elements, with three ajax buttons: 
> > add, remove and save (adding/removing a row and persisting the list)
>
> The first solution I described involving hidden fields will definitely
> work. I don't think you need to do 2 ajax calls (one for the form and
> one for the button) but piggy back the button information into a
> hidden field and only submit the form:
>
> Perhaps something like:
>
> <button onclick={(JqId("hidden_field_id") >> JqAttr("value", "add")) +
> + SHtml.submitAjaxForm(form_ID).toJsCmd}>blah</button>
>
>
>
> > By the way, I think there's a small inconsistency; there are 7 overloaded 
> > variants for ajaxButton:
>
> > ajaxButton(text: NodeSeq, func: () => JsCmd, attrs: (String, String)*): Elem
> > ajaxButton(text: String, func: () => JsCmd, attrs: (String, String)*): Elem
>
> > ajaxButton(text: NodeSeq, jsFunc: Call, func: () => JsCmd, attrs: (String, 
> > String)*): Elem
> > ajaxButton(text: String, jsFunc: Call, func: () => JsCmd, attrs: (String, 
> > String)*): Elem
>
> > ajaxButton(text: NodeSeq, jsExp: JsExp, func: String => JsCmd, attrs: 
> > (String, String)*): Elem
>
> > and the last one doesn't have a text: String counterpart. Also the javadoc 
> > for the last variant is missing information on what's "jsExp" and what's 
> > the argument passed to "func". My guess would be that jsExp is evaluated 
> > and the result passed to func on the server?
>
> Yes jsExp is being evaluated and its result is being sent to server.
> Please open a defect for this inconsistency.
>
>
>
> > --
> > Adam
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to