In my ScalaJS project I use Semantic-UI with scala-js-jquery
I use this to monkey patch 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]
For example $('select.dropdown').dropdown();
translates to jQuery(".ui.dropdown").dropdown(js.Dynamic.literal(on = "hover")).
My problem now is how to translate this:
// custom form validation rule
$.fn.form.settings.rules.adminLevel = function(value, adminLevel) {
return (window.user.adminLevel >= adminLevel)
};