That is surprising...

revised function:

  def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
      SHtml.ajaxForm(body ++ SHtml.hidden(func))
  }

very cool!

thanks,

- jon

On Aug 12, 11:51 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Wed, Aug 12, 2009 at 8:14 AM, jon <jonhoff...@gmail.com> wrote:
>
> > Thanks Dave,
>
> > I explored both of those routes.  The hidden field would allow me to
> > execute on the server, but not send back JS to execute on the client.
> > The ajaxButton would allow me to execute code on the client, but not
> > submit the form (unless I put the form serialize code in the
> > button?).  I wanted the JS code to vary depending on input from the
> > whole form submission.
>
> Try it... you'll be surprised.
>
> If you have a SHtml.hidden() that returns a JsCmd, that JsCmd will be sent
> to the browser.
>
>
>
>
>
>
>
> > On Aug 11, 8:17 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > wrote:
> > > On Tue, Aug 11, 2009 at 3:31 PM, jon <jonhoff...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I'm not sure if this behavior already exists via some other mechanism,
> > > > but I wanted an ajaxForm that executed a JsCmd sent from the sever
> > > > after submit.  Here it is:
>
> > > >        def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
> > > >          val id = Helpers.nextFuncName
>
> > > >          fmapFunc(func)(name => <form action="javascript://" id={id}
> > > > onsubmit={makeAjaxCall(LiftRules.jsArtifacts.serialize(id)).toJsCmd+";
> > > > return false;"}> <input type="hidden" name={name} value="true"/> {body}
> > > > </form>)
> > > >        }
>
> > > > Is there a better way?
>
> > > You could use an ajaxButton to update the div... alternatively, put an
> > > SHtml.hidden field in the form itself.
>
> > > >  jsonForms seemed like a bit of overkill to do
> > > > what i wanted=> simple update of div after submit.
>
> > > > - Jon
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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