Hi,
I would like the user to be able to resize the main divs in my play/scala.js app, so I’m trying to use the jquery-ui resizable() function.
I first added a jquery-ui facade as follows:
import scala.scalajs.js
import org.scalajs.jquery._
import scala.language.implicitConversions
object JQueryUi {
implicit def jquery2ui(jquery: JQuery): JQueryUi =
jquery.asInstanceOf[JQueryUi]
}
trait JQueryUi extends JQuery {
def resizable(options: js.Any): JQueryUi = js.native
}
The jquery and jquery-ui definitions are included via webjar in index.scala.html:
<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))'></script>
<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("jquery-ui.min.js"))'></script>
Then I tried to call the resizable() function, which compiles, but fails at runtime with the javascript message:
Uncaught TypeError: jquery.resizable is not a function
Here is the code that calls it:
import org.scalajs.dom._
import org.scalajs.dom.raw.Node
import scala.scalajs.js
import scalacss.ScalatagsCss._
import scalatags.JsDom.all._
import org.scalajs.jquery.{ jQuery ⇒ $, _ }
import JQueryUi._
case class Layout() extends Displayable {
val wrapper = div(Styles.layout).render
$(wrapper).resizable(js.Dynamic.literal {
"handles" -> "e,s,w"
// ...
})
override def markup(): Element = wrapper
def addItem(node: Node): Unit = {
wrapper.appendChild(node)
}
}
Any idea why this is not working? Any suggestions?
Would using jquery-facade be of help here?
Thanks,
Allan
I would like the user to be able to resize the main divs in my play/scala.js app, so I’m trying to use the jquery-ui resizable() function.
I first added a jquery-ui facade as follows:
import scala.scalajs.js import org.scalajs.jquery._ import scala.language.implicitConversions object JQueryUi { implicit def jquery2ui(jquery: JQuery): JQueryUi = jquery.asInstanceOf[JQueryUi] } trait JQueryUi extends JQuery { def resizable(options: js.Any): JQueryUi = js.native }
Would using jquery-facade be of help here?
Any suggestions on the best way to manage javascript and CSS dependencies in a Play/ScalaJS app?