Reputation: 5270
I have some optional parameters I want to use to initialise a JQuery widget that are passed as
Iterable[(String, String)]
What is the best way to convert this object to a js.Dynamic
?
Upvotes: 1
Views: 104
Reputation: 22085
Probably the following:
val seq = iterable.toSeq
val dict = js.Dictionary(seq: _*)
val dynamic = dict.asInstanceOf[js.Dynamic]
You can of course make it into a single expression:
js.Dictionay(iterable.toSeq: _*).asInstanceOf[js.Dynamic]
Upvotes: 2