Derek, Here is my complete head method:
def head = <head><script type="text/javascript" src={"/" + LiftRules.resourceServerPath + "/jlift.js"} /> {Script(json.jsCmd)}</head> Also, why do you use variable binding in your case pattern (j @ JsonCmd ("processForm"...). You don't refer to the variable anywhere in the function body, so this should work just as nicely without it (case case JsonCmd("processForm"...) Glenn On Sep 16, 10:11 am, Derek Chen-Becker <dchenbec...@gmail.com> wrote: > I'll fix the book right now, but could you please send your complete head > method so that I make sure to include the correct code? > > Derek > > On Wed, Sep 16, 2009 at 9:30 AM, glenn <gl...@exmbly.com> wrote: > > > Marius, > > > You are right. I added <script type="text/javascript" src={"/" + > > LiftRules.resourceServerPath + "/jlift.js"} /> to > > my head method, and everything works great. The issue here, is that > > the Lift Book example doesn't mention > > this. > > > Glenn > > > On Sep 15, 9:07 pm, "marius d." <marius.dan...@gmail.com> wrote: > > > Right ... the head method should not have the js script but did you > > > include the jlift.js script in your default template? > > > > I'll build an example this week (when I'll find some time for it) and > > > see if I'm running into the same problems as you are. If you somehow > > > manage to fix it please let me know. How urgent is this for you? > > > > Br's, > > > Marius > > > > On Sep 15, 6:15 pm, glenn <gl...@exmbly.com> wrote: > > > > > But, the head method does add the javascript to the page, so no src > > > > attribute is needed, right? > > > > > On Sep 15, 3:59 pm, "marius d." <marius.dan...@gmail.com> wrote: > > > > > > Where is the head function in your code ? > > > > > > Here is an example: > > > > > > def head = <head><script type="text/javascript" src="/classpath/ > > > > > jlift.js" /> {Script(json.jsCmd)}</head> > > > > > > Br's, > > > > > Marius > > > > > > On Sep 15, 5:55 pm, "marius d." <marius.dan...@gmail.com> wrote: > > > > > > > Do you see any errors in FireBug ? ... Do see the Ajax request > > being > > > > > > send out in FireBug? > > > > > > > On Sep 15, 5:49 pm, glenn <gl...@exmbly.com> wrote: > > > > > > > > Derek, > > > > > > > > Here is the template. Just as in the book. > > > > > > > > <lift:surround with="default" at="content"> > > > > > > > <lift:JSONForm.head /> > > > > > > > <lift:JSONForm.show> > > > > > > > <input type="text" name="name" /> > > > > > > > <br /> > > > > > > > <input type="text" name="value" /> > > > > > > > <br /> > > > > > > > <input type="radio" name="vehicle" value="Bike" /> > > > > > > > <input type="radio" name="vehicle" value="Car" /> > > > > > > > <input type="radio" name="vehicle" value="Airplane" /> > > > > > > > <br /> > > > > > > > <select name="cars" > > > > > > > > <option value="volvo">Volvo</option> > > > > > > > <option value="saab">Saab</option> > > > > > > > <option value="opel">Opel</option> > > > > > > > <option value="audi">Audi</option> > > > > > > > </select> > > > > > > > <button type="submit">Submit</button> > > > > > > > </lift:JSONForm.show> > > > > > > > <div id="json_result"></div> > > > > > > > </lift:surround> > > > > > > > > And here is my JSONForm class: > > > > > > > > class JSONForm { > > > > > > > > def head = <head>{Script(json.jsCmd)}</head> > > > > > > > def show(html: Group): NodeSeq = { > > > > > > > json.jsCmd > > > > > > > SHtml.jsonForm(json, html) > > > > > > > } > > > > > > > > object json extends JsonHandler { > > > > > > > def apply(in: Any): JsCmd = > > > > > > > SetHtml("json_result", Text("This is a test")) > > > > > > > > } > > > > > > > > } > > > > > > > > Here, I just simplified the JsCmd returned from the handler. > > > > > > > > I understand that in the head method, the call to json.jsCmd > > creates > > > > > > > the ajax handler (from the apply method), but clicking on the > > submit > > > > > > > button on the form doesn't populate the json_result div. In fact, > > > > > > > it doesn't do anything even though, on the page source, the > > button's > > > > > > > onclick method is > > > > > > > wired up. > > > > > > > > Glenn > > > > > > > > On Sep 15, 11:59 am, Derek Chen-Becker <dchenbec...@gmail.com> > > wrote: > > > > > > > > > The apply method should be getting called because the > > SHtml.json method > > > > > > > > should register it as the handler for the form. Would you mind > > sending me > > > > > > > > the code you have and I'll take a look at it? I'm pretty sure > > this code was > > > > > > > > working at one point, but perhaps something has changed. > > > > > > > > > Derek > > > > > > > > > On Mon, Sep 14, 2009 at 2:03 PM, glenn <gl...@exmbly.com> > > wrote: > > > > > > > > > > Actually, the JsonHandler in the example gets called, but not > > the apply > > > > > > > > > (in:Any) method, as > > > > > > > > > that is never called in the book example. Also, the handler > > seems to > > > > > > > > > be called twice with every submit. > > > > > > > > > Why is that? > > > > > > > > > > Glenn > > > > > > > > > > On Sep 14, 8:08 am, glenn <gl...@exmbly.com> wrote: > > > > > > > > > > This may be a question for the Lift Book forum, but has > > anyone gotten > > > > > > > > > > the JSON forms example 8.13 in the Lift Book to work? When > > I tried > > > > > > > > > > it, the JsonHandler in class JSONForm never gets called > > when the > > > > > > > > > > submit button is clicked. > > > > > > > > > > > Glenn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---