0

In JQuery mobile, to make persistent headers, footers and nabbers work as expected, you have to do something like this:

$(function() {
    $( "[data-role='navbar']" ).navbar();
    $( "[data-role='header'], [data-role='footer']" ).toolbar();
});

What is the equivalent in Scala.js?

rabejens
  • 7,594
  • 11
  • 56
  • 104

1 Answers1

1

As usual in Scala.js, as a first "draft" you can always use the dynamically typed API:

js.Dynamic.global.$("[data-role='navbar']").navbar()

If you want a statically typed API, you can define it. As far as I know, no one has written facade types for jQuery mobile yet. However, there are facades for jQuery itself, such as 1. You can then "pimp" additional methods provided by a jQuery plugin, such as jQuery mobile, using the monkey patching pattern for Scala.js facades:

import org.querky.jquery._

trait JQueryMobile extends JQuery {
  def navbar(): Unit
}

implicit def JQueryMobileOps(jQ: JQuery): JQueryMobile =
  jQ.asInstanceOf[JQueryMobile]

and then you can do:

$("[data-role='navbar']").navbar()

and it will be statically typechecked.

sjrd
  • 21,805
  • 2
  • 61
  • 91