【发布时间】:2018-09-13 22:39:43
【问题描述】:
在我的 ScalaJS 项目中,我使用 Semantic-UI 和 scala-js-jquery
我用它来修改 JQuery:
// Monkey patching JQuery
@js.native
trait SemanticJQuery extends JQuery {
def dropdown(params: js.Any*): SemanticJQuery = js.native
def popup(params: js.Any*): SemanticJQuery = js.native
// and more
}
// Monkey patching JQuery with implicit conversion
implicit def jq2semantic(jq: JQuery): SemanticJQuery = jq.asInstanceOf[SemanticJQuery]
例如$('select.dropdown').dropdown();
翻译成jQuery(".ui.dropdown").dropdown(js.Dynamic.literal(on = "hover"))。
我现在的问题是如何翻译这个:
// custom form validation rule
$.fn.form.settings.rules.adminLevel = function(value, adminLevel) {
return (window.user.adminLevel >= adminLevel)
};
【问题讨论】:
标签: jquery semantic-ui scala.js