On Fri, Dec 11, 2009 at 8:21 AM, Nolan Darilek <no...@thewordnerd.info>wrote:
> Hello. Sorry for being the squeaky wheel on this one, but I'm really at > a loss with no way to know if this is an issue with me, or with how I'm > doing things in Lift. I've also been at this particular problem for a > bit under a day now, and am running out of things to try and words to > google. > > I think I figured out yesterday's issue--likely should have set onclick > to an anonymous function returning false to prevent the browser from > running it in a new DOM--but I've decided to chage my approach slightly. > For various reasons, I'm now trying to use a <select/> with an onBlur > handler which submits the value, a JSON string, to a function via > jsonCall. Here is my entire function, still with a few rough edges as I > add in the various AJAX bits: > > def updatePosition(pos:Any):JsCmd = pos match { > case p:Map[String, Double] => > GeoNode.nearestTo(p("lat"), p("lon")) match { > case Some(node) => > val nodes = node.within(0.001).remove(n => n.ways.size == 1) > val nodeList = <select onblur = { > JsRaw("alert(\"Blur!\")") > }> You're making things way too complex: <select onblur="alert('Blur!')"> > { > nodes.map(n => > <option value={JsObj("lat" -> n.latitude, "lon" -> > n.longitude)}> value={JsObj("lat" -> n.latitude, "lon" -> n.longitude)} does not do what you think it does. You can't put a JSON object in the attribute of an HTML element. When the item is selected, what do you want to happen? > {n.name(None, None).getOrElse("Unnamed node")}</option> > ) > }</select> > println(nodeList) > Replace("location", node.nearestWay match { > case Some(w) => <p>On {w.name.getOrElse("Unnamed way")}.</p> > case None => <p>No nearby ways</p> > }) & > Replace("nearby", nodeList) > case _ => Replace("location", <p>Thar be dragons! (You don't > appear to be on any current maps.</p>) > } > case _ => > println(pos) > Alert("Unexpected geolocation API response from browser.") > } > > No matter what I try, I can't get the alert() to trigger when I tab off > the <select/>. The println outputs what appears to be a sane value. I've > inspected the element in Firebug, and everything appears as I'd expect. > I've saved the entire page body with everything inserted, and everything > looks fine there too. I've even done up a simple HTML document to make > sure this behaves as I'd expect, and it does exactly what I think it > should. > > So, what am I missing? Is embedded JS in a Replace call not run or > something odd like that? > > -- > > 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<liftweb%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- 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.