JQuery Mobile and Scala.js: How to call functions like “navbar()” or “toolbar()”?

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?


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


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 =

and then you can do:


and it will be statically typechecked.

Need Your Help

How to keep collections of viewmodels and models in sync

wpf viewmodel observablecollection

I'm using the wpf toolkit datagrid to display an observable collection of AccountViewModels.

Why can't I define a default constructor for a struct in .NET?

c# .net struct

In .NET, a value type (C# struct) can't have a constructor with no parameters. According to this post this is mandated by the CLI specification. What happes is that for every value-type a default