Questions tagged [scala.js]

Scala.js is a Scala to JavaScript compiler deemed production-ready as of version 0.6.0.

Scala.js compiles Scala code to JavaScript, allowing you to write your Web application entirely in Scala!

Noteworthy features:

  • Support all of Scala, modulo a few semantic differences
  • Very good interoperability with JavaScript code. For example, use jQuery and HTML5 from your Scala.js code, either in a typed or untyped way. Or create Scala.js objects and call their methods from JavaScript.
  • Integrated with sbt (including support for dependency management and incremental compilation)
  • Can be used with your favorite IDE for Scala
  • Generates Source Maps for a smooth debugging experience (step through your Scala code from within your browser supporting source maps)
  • Integrates Google Closure Compiler for producing minimal code for production.

Find out more at scala-js.org

845 questions
0
votes
1 answer

Declare js dependencies in sbt

Here is a build.sbt file from https://github.com/jducoeur/bootstrap-datepicker-scalajs : import SonatypeKeys._ sonatypeSettings lazy val root = project.in(file(".")). enablePlugins(ScalaJSPlugin) name := "Scala.js facade for…
qed
  • 22,298
  • 21
  • 125
  • 196
0
votes
2 answers

Call jquery .each method from scala.js

Is this doc out-dated? http://www.scala-js.org/doc/calling-javascript.html Can't seem to get this right in intellij: import org.scalajs.dom.html import org.scalajs.dom import org.scalajs.dom.raw.HTMLElement import scala.scalajs.js import…
qed
  • 22,298
  • 21
  • 125
  • 196
0
votes
1 answer

Set a limit to scala.rx timer

Here is an example using Timer from scala.rx: package tutorial.webapp import akka.actor.ActorSystem import rx.core.{Rx, Var} import rx._ import rx.ops._ import scala.concurrent.Promise import scala.concurrent.duration._ import…
qed
  • 22,298
  • 21
  • 125
  • 196
0
votes
1 answer

Can't build a simple project with Lift and Scala.js

I made this simple project: https://github.com/eje211/scalajswithlift I tried to create a JSON object with Lift DSL and print it in the HTML console with Scala.js . But I get this error: [info] Compiling 1 Scala source to…
eje211
  • 2,385
  • 3
  • 28
  • 44
0
votes
1 answer

Correct usage of js.ThisFunction0

I am trying to get scala.js working in conjunction with the w2ui jQuery library. However, when I define my reset action in a form, the behaviour is not as I would have expected. In order to handle my reset action. I define something like the…
user79074
  • 4,937
  • 5
  • 29
  • 57
0
votes
1 answer

ScalaJS: Facade for polymorphic object

I would like to call, from ScalaJS, a JS function similar to the following: function parseExpression(s){ if(isNumber(s)) return {lit:s} else{ return { left : leftOp(s) oper : operand(s) right: rightOp(s) } } } where…
Eduardo
  • 8,362
  • 6
  • 38
  • 72
0
votes
1 answer

Scala-js jquery hover type error

Using scalajs-jquery 0.8.0, under the following import assumptions: import org.scalajs.jquery.{jQuery => $`, the following does not compile: import dom.html.Element The following code does not compile, which is my problem: …
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
0
votes
1 answer

How to manipulate the meta area of the HTML dom with Scala-JS for a single page application

General Scala-JS page building advice needed. Most of the examples seem to be of the pattern where the main into which your single page application will go is between the tags in a landing page html file. How do you handle the need to insert…
bjenkins001
  • 141
  • 1
  • 9
0
votes
2 answers

Is it some alternatives to "implements" traits with ScalaJs and Javascript

I have this code that I would like to be able to execute as Javascript : @JSExport class Feeder { @JSExport def feed(feedable: Feedable): Unit = { feedable.feed(); } } trait Feedable { def feed() } Of course traits cannot be exported,…
gervais.b
  • 2,294
  • 2
  • 22
  • 46
0
votes
1 answer

scala-js unexpected checks resulting to undefined behavior

Running the following Scala code compiled into scala-js version 0.8.0, I get the following error: An undefined behavior was detected: undefined is not an instance of java.lang.String trait MyDataType extends js.Any { var wordy: String =…
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
0
votes
2 answers

How to convert Map to Json object in Scala.js?

I'm trying to write a facade for C3.js line chart. The Javascript code I'm trying to generate is var chart = c3.generate({ data: { json: { "data1": [49.1, 20, 50, 40, 60, 50], "data2": [200.3, 130, 90, 240, 130,…
user794783
  • 3,619
  • 7
  • 36
  • 58
0
votes
2 answers

JQuery UI spinner spin event not as expected in Scala JS

When I define a spinner in ScalaJS and handle the spin value I am not able to get the new spin value in the event as I would have expected. According to the JQuery UI documentation the second parameter to the spin event is the ui object that…
user79074
  • 4,937
  • 5
  • 29
  • 57
0
votes
0 answers

Making package a dependency of a new sbt task

When at the sbt CLI I can just type package and everything works fine - two jar files are produced. But I want to make package a dependency of a new task I am creating, so I want to make packaging happen as part of the build script. This is what I…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
0
votes
1 answer

Variance with js.Array

I have a javascript method that accepts js.Arrays that can contain objects of multiple types. E.g js.Dates or Integers or Strings How I can model that without having to cast any of these types. def domain(p: js.Array[js.Any]) does not work…
0
votes
1 answer

Should be using `target` rather than `srcElement` in Scala.js

I have some Scala.js code which works fine when the target-browser is Chrome but not when it is Firefox. I have been told that I should not use srcElement but instead target. However I can't work out how to access target. private def TD(locId:…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42