Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4322026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:49:15+00:00 2026-05-21T08:49:15+00:00

My goal is to have text displayed normally on initial load, but when an

  • 0

My goal is to have text displayed normally on initial load, but when an ‘Edit’ button is pressed, the text changes to be an input text box. The html is this:

<div class="user">
    <div>
        <span>Edit</span><lift:WiredUser.edit />
    </div>
    <div class="details">
        <lift:WiredUser.email />
    </div>
</div>

My wiring class looks like so:

class WiredUser {

  val userToWire = (Users.userForDisplay or userDetail.currentValue).get

  private object User {
    val entity = ValueCell(userToWire)
    val edit = ValueCell(false)
    val email = edit.lift(b => entity.lift(_.getEmail.asScala.headOption).get)
  }

  def edit = {
    WiringUI.toNode(User.edit, JqWiringSupport.fade)((mode: Boolean, ns:NodeSeq) => { Wired.editable(
      mode,
      mode,
      (b: Boolean) => ajaxButton(h("Done"), () => {User.edit.set(false); JsCmds.Noop}),
      (b: Boolean) => ajaxButton(h("Edit"),  () => {User.edit.set(true); JsCmds.Noop})
    )})
  }

  def email = WiringUI.toNode(User.email, JqWiringSupport.fade)((email: Option[String], ns: NodeSeq) => {
    Wired.editable(
      email.getOrElse(""),
      User.edit.get,
      (n: String) => ajaxText(n, s => {refresh(setEmail(_, s)); JsCmds.Noop}),
      (n: String) => h(n)
    )
  })
}

object Wired {

   def editable[T](o: T, mode: Boolean, t: (T)=> NodeSeq, f: (T) => NodeSeq) : NodeSeq = {
     mode match {
       case true => t(o)
       case false => f(o)
     }
   }
}

On initial load, there is an ‘Edit’ button that is displayed. When that button is pressed, an ajax call with the form data “F531904251245BAWYT:true” is executed, however the function attached to the ajax call is never executed: () => {User.edit.set(true); JsCmds.Noop} and the result is empty:

jQuery(document).ready(function() {
});

Any thoughts on what I might be missing?

Note that I have submitted this to the Lift google group without a response.

I have created a working example:
https://github.com/OleTraveler/scala-wiring-example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:49:16+00:00Added an answer on May 21, 2026 at 8:49 am

    I have faced with the same problem and I’ve found some solution. I created my custom version of net.liftweb.WiringUI (MyWiringUI), where I changed the following methods

      def toNode[T](in: NodeSeq, cell: Cell[T], jsEffect: (String, Boolean, JsCmd) => JsCmd)(f: (T, NodeSeq) => NodeSeq): NodeSeq = {
    val myElem: Elem = in.find {
      case e: Elem => true
      case _ => false
    }.map(_.asInstanceOf[Elem]).getOrElse(<span id={Helpers.nextFuncName}>{in}</span>)
    
    val (elem: Elem, id: String) = Helpers.findOrAddId(myElem)
    addJsFunc(cell, (t: T, first: Boolean) => {
      jsEffect(id, first, SetHtml(id, f(t, elem.child)))
    })
    f(cell.currentValue._1, elem)
    

    }

    and

      def addJsFunc[T](cell: Cell[T], f: (T, Boolean) => JsCmd) {
    for {
      cometActor <- S.currentCometActor
    } cell.addDependent(cometActor)
    
    val trc = TransientRequestCell(cell)
    var lastTime: Long = 0L
    var lastValue: T = null.asInstanceOf[T]
    for {
      sess <- S.session
    } sess.addPostPageJavaScript(() => {
      val (value, ct) = trc.get
      val first = lastTime == 0L
      if (first || (ct > lastTime && value != lastValue)) {
        lastValue = value
        lastTime = ct
        if(first) Noop
        else f(value, first)
      }else{
        Noop
      }
    })
    

    }

    The most important change is:

            if(first) Noop
        else f(value, first)
    

    Thats all.

    Whole example you can find at here https://github.com/mmigacz/lift_wiring

    Some additional information about my problem you can find on lift forum https://groups.google.com/group/liftweb/browse_thread/thread/932ce4d45ccd6582?hl=pl

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal was to have a template function that would take as an input
My goal is to have a text area that automatically resizes to whatever horizontal
Right now my goal is to have anti-aliased text on my Labels. If my
In Drupal 6, I have created a view, displayed as a block. My goal
goal: I have the string 1234432144 I want to only replace the first 2
Let me first describe my goal: I have created an object with 3 properties:
My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is
My goal is to have a jQuery datepicker pop up when the user clicks
My goal is to have a user select a year and a month. Translate
My goal is to have more themes for my application and if possible, bundle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.