On Jan 16, 12:02 pm, Adam Warski <a...@warski.org> wrote:
> Hello,
>
> > Ok I just looked on your code. The problem is that you put the ajax
> > button inside the form and there is not reason for that.
>
> Well, unless I do want the button to be inside the form ;) (for 
> user-experience/layout reasons). Although it's possible to hack this with css 
> somehow.
>
>
>
> > I changed your code to something like:
>
> >    bind("cont", containerTemplate,
> >      "name" -> { println("bind container name " + cont.name);
> > SHtml.text(cont.name,
> >              (s: String) => {println("set container name " + s);
> > cont.name = s; }) },
> >      "rooms" -> editRoom _
> >      ) ++ ajaxButton(Text("Add"), "cont_edit",
> >        () => { println("executing funtion"); cont.rooms += new Room;
> > reDraw })
>
> > So the button is outside the form now. Otherwise your dynamic added
> > field were appended in the form after the add button location. I
> > removed from your template <cont:add /> (or whatever the name was). I
> > tested it and the behavior appears correct to me now. Field values are
> > preserved correctly.
>
> Hmm yes I wondered if the order in which the functions are bound is 
> significant, but my experiments showed that it's not simply a "first bound, 
> first called" principle. So I don't quite get it yet why it doesn't work.

We rely on JQuery (or other underlying library) to send the actual
ajax request. We feed in the correct sequence but if your button is in
the middle of the form (as fields were added after the button's
location in the form) the sequence of the function id-s is not sent
right via ajax even if onclick for the ajax button we first serialize
the for and then add the function ID of the ajax button. Personally I
don't see why this is an impediment

>
> Anyway, thanks a lot for taking the time and checking the code. I'll simply 
> use an ajaxForm for now, as I don't really have to use normal forms. Just 
> wanted to check if it's possible ;).

It is possible and easy. Just put your ajax button outside the form.

>
> --
> 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