Hi,

Something puzzled me about this as in firebug the parameters order was
correct. So here is the explanation why it doesn't for with your code:

1. HTTP parameters MAY arrive in an unpredictable order into the
servlet. Container may alter their order due to use of maps etc, or
browsers may even alter it. The point is that parameters order for
"application/x-www-form-urlencoded" is not specified.
2. Even if the ajax request was sent with the right order (the one
that we expected) Lift DOES the parameter sorting. This is imperative
to ensure proper execution order for form functions. Thus since the
function names that were added after you press the "Add" button are
lexicographically > then your "submit function name" (there is an
algorithm generating form function names), your submit function was
processed BEFORE those fields function.

To cope with this I modified your ajaxButton to:

  def ajaxButton(text: NodeSeq, formId: String, func: () => JsCmd,
                 attrs: (String, String)*): Elem = {
    val name = "Z" + Helpers.nextFuncName
    addFunctionMap(name, contextFuncBuilder(func))

    attrs.foldLeft(
            <button onclick={makeAjaxCall(JsRaw(
              LiftRules.jsArtifacts.serialize(formId).toJsCmd + " + "
+ Str("&" + name + "=true").toJsCmd)).toJsCmd +
                    "; return false;"}>{text}</button>)(_ % _)
  }


This will ensure that your submit function will be called last. I did
some a testing with your code and having only ajaxButton changes and
the behavior was correct.


Br's,
Marius

On Jan 18, 10:36 am, Adam Warski <[email protected]> wrote:
> Hello,
>
> > Right ... and it's not even a hack ... css is the right way of
> > building layout not really the html. Putting buttons "in the form" ar
> > giving this perception in the page doesn't mean that the button has to
> > be physically in the form element (at least that's the way I see
> > it.).
>
> actually I think I'll take back the "doable with CSS" as it's quite easy for 
> an "add element" button, but per-element operations, like "delete", "move 
> up", "move down" would take really some more time to layout properly, if they 
> were placed outside the form :).
>
> But as I said, I'll make the whole form AJAX :).
>
> --Adam
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to