목표는 초기로드시 텍스트를 정상적으로 표시하는 것이지만 '편집'버튼을 누르면 텍스트가 입력 텍스트 상자로 변경됩니다. html로는 이것이다 :리프트 배선을 사용할 때 ajaxButton이 작동하지 않습니다.
<div class="user">
<div>
<span>Edit</span><lift:WiredUser.edit />
</div>
<div class="details">
<lift:WiredUser.email />
</div>
</div>
내 배선 클래스는 그래서 다음과 같습니다
초기로드에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)
}
}
}
가 표시됩니다 '수정'버튼이 있습니다. 이 버튼을 누르면 양식 데이터 "F531904251245BAWYT : true"를 가진 ajax 호출이 실행되지만 ajax 호출에 첨부 된 함수는 절대로 실행되지 않습니다.() => {User.edit.set (true); JsCmds.Noop}이고 결과는 비어 있습니다.
jQuery(document).ready(function() {
});
내가 누락 된 부분에 대한 의견이 있으십니까?
응답없이 Google 그룹에 제출했습니다.
나는 작업 예를 만들었습니다 : 저도 같은 문제에 직면 한 https://github.com/OleTraveler/scala-wiring-example
감사를 찾을 수 있습니다. 필자는 현재 다른 기능으로 이동 했으므로이 기능을 테스트하기까지 2 ~ 3 주 정도 소요될 것입니다. – OleTraveler