Greetings Joachim! My experience with replaceWith has been troublesome at best. IE6 (and in some cases IE7) crashes when trying to replace certain elements.
I was able to work around it by only replacing the contents of ceertain elements. (TR, TABLE, THEAD etc cause intermittent IE6 crashes when replaced) Just a heads up! /Viktor On Wed, Jan 21, 2009 at 1:25 PM, Joachim A. <[email protected]>wrote: > Hi Lift coders, > I found several additions to JqJsCmds quite helpful. > I attached the source code. > > Basically it's a few JsExp and a few objects, like the other JqJsCmds > constructs. > It includes Remove, ReplaceWith and toggle. Toggle is probably not very > useful > for most because it renders html which may not fit for other projects. > apply(...) of Toggle includes a call to XHtml.randomId which just returns a > new HTML id. I guess there's a Lift equivalent for it but I was unable to > find > it. > > If you like please include the things you find helpful in JqJsCmds. If > necessary I can provide a patch for JqJsCmds. > > Thanks a lot for Lift, which is a pleasure to use, > Joachim > > > > > > > package de.ansorgs.clouds.lib.lift > > import _root_.net.liftweb.http.js.jquery.{JQueryLeft, JqJE, JQueryRight} > import _root_.net.liftweb.http.js.{JE, JsCmd, JsExp, JsCmds} > import _root_.scala.xml.{Text, NodeSeq} > import MoreJs.{JqRemove, JqToggle} > > /** > * Collection of several JQuery JavaScript extensions to the original Lift > JqJsCmds. > */ > object MoreJs { > import JsCmds.jsExpToJsCmd > > /** > * JsExp which removes the result of the jQuery match. > */ > case class JqRemove() extends JsExp with JQueryRight { > override def toJsCmd = "remove()" > } > > /** > * JsExp which replaces the result of a JQuery match with something new. > */ > case class JqReplace(content: NodeSeq) extends JsExp with JQueryRight { > override def toJsCmd = "replaceWith(" + fixHtml("inline", content) + ")" > } > > /** > * JsExp which toggles the result of the JQuery match. > */ > case class JqToggle() extends JsExp with JQueryRight { > override def toJsCmd = "toggle()" > } > > /** > * This object helps with the removal of the content of JQUery selectors. > */ > object Remove { > /** > * This removes the element with the given id from the xhtml document. > * @param The if of the html parameter to match. > * @return the JsCmd which executes the JQuery command > */ > def apply(uid: String): JsCmd = JqJE.JqId(JE.Str(uid)) >> JqRemove() > } > > /** > * Replace an element with an id with the given new content. The original > element is removed and > * the new content is added instead. > */ > object ReplaceWith { > def apply(uid: String, content: NodeSeq): JsCmd = JqJE.JqId(JE.Str(uid)) > >> JqReplace(content) > } > > /** > * Encloses the content in a toggleable div. The default is hidden. > * It generates a random id which is used for the toggle effect. > */ > object Toggle { > def apply(title: String, content: NodeSeq): NodeSeq = { > if (content.isEmpty) return NodeSeq.Empty > > val id = JE.Str(XHtml.randomId) > val onClick: JsExp = JqJE.JqId(id) >> JqToggle() > > <div> > <a href="#" onclick= {JE.Str(onClick.toJsCmd)}> {Text(title)} </a> > <div id= {id} style="display:none;"> {content} </div> > </div> > } > } > } > -- Viktor Klang Senior Systems Analyst --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
