On Tue, Dec 29, 2009 at 7:44 AM, greekscala <[email protected]> wrote:
> Hello, > > In a previous post I had the problem that my form was not send with > ajax. > With the help of Marius and Timothy I got it working. > (http://groups.google.com/group/liftweb/browse_thread/thread/ > d052ed7191561ef1<http://groups.google.com/group/liftweb/browse_thread/thread/%0Ad052ed7191561ef1> > ) > > I have to questions. > > Now I want, after the form is submittet, to fetch an object from my DB > do something > and update the site. > > I tried the following: > def add(xml: NodeSeq): NodeSeq = { > > def addBookmark(): JsCmd = { > // fetch the object from DB > > JsCmds.SetHtml(WebHelper.MAIN_DIV_ID, > TemplateFinder.findAnyTemplate > (WebHelper.bookmarkEdit).open_!) > } > > SHtml.ajaxForm( > bind("bookmark", xml, > "url" -> SHtml.text(url, url = _), > "submit" -> SHtml.submit("add", addBookmark) > ), JsCmds._Noop, addBookmark > ) > } > > I hoped that the addBookmark method would be invoked after the form > is submitted and that the returned SetHtml will set the new snippet > fragment (that should be processed by lift). > The new fragment is a new form: > <lift:Bookmark.edit> > <bookmark:url /> > <bookmark:title /> > <bookmark:submit /> > </lift:Bookmark.edit> > > Is there a better way to do such ajax fragment replacements? would > like to know more about. > I can't think of a better way right now; what you're doing is pretty standard. > Are the NodeSeq that should be replaced with SetHtml processed by > Lift? > Not unless you're specifically calling templates, etc. > The second thing is, that when I am trying to make a browser request > to view the page, > the addBookmark method is already executed. Was this intended? > No, that's not supposed to happen. I'm guessing you're calling addBookmark() somewhere else in your code. alex -- 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.
