Is there a JsAnd or JsOr when generate JS in lift?

女生的网名这么多〃 提交于 2019-12-11 13:04:34

问题


I know this is very much a noob question...

I see lift provides utilities methods to generate javascript commands. I want to do the equivalent of:

JsIf((JsEq(ValById("disable-production"),JsTrue) || JsEq(ValById("disable-production"), JsTrue) , {
        Alert("Do something interesting...")
      })

Thanks.


回答1:


Yes, there is:

import net.liftweb.http.js.JsCmds._
import net.liftweb.http.js.JE._

val conditional = JsIf(
  JsOr(
    JsEq(ValById("disable-production"), JsTrue),
    JsEq(ValById("disable-something-else"), JsTrue)
  ),
  Alert("Do something interesting...")
)



回答2:


You would probably be better off writing this directly in string form and then evaluating it using JsExp.strToJValue(<your expression>).

However, the direct answer to your question would be JE.JsOr.

JsIf((JE.JsOr(JsEq(ValById("disable-production"),JsTrue),
             JsEq(ValById("disable-production"), JsTrue)) , {
    Alert("Do something interesting...")
  })


来源:https://stackoverflow.com/questions/11300263/is-there-a-jsand-or-jsor-when-generate-js-in-lift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!