Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/udashframework/scala-js-jquery
Static types for the jQuery API for Scala.js programs.
https://github.com/udashframework/scala-js-jquery
hacktoberfest jquery jquery-api scala scala-js-jquery scala-js-wrapper scalajs
Last synced: about 1 month ago
JSON representation
Static types for the jQuery API for Scala.js programs.
- Host: GitHub
- URL: https://github.com/udashframework/scala-js-jquery
- Owner: UdashFramework
- License: apache-2.0
- Created: 2016-01-27T11:25:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T10:19:29.000Z (about 1 year ago)
- Last Synced: 2024-03-26T16:25:08.106Z (9 months ago)
- Topics: hacktoberfest, jquery, jquery-api, scala, scala-js-jquery, scala-js-wrapper, scalajs
- Language: Scala
- Homepage:
- Size: 168 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# udash-jquery [](http://www.avsystem.com/)
[![CI](https://github.com/UdashFramework/scala-js-jquery/actions/workflows/ci.yml/badge.svg)](https://github.com/UdashFramework/scala-js-jquery/actions/workflows/ci.yml)[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.13)
[![Join the chat at https://gitter.im/UdashFramework/scala-js-jquery](https://badges.gitter.im/UdashFramework/scala-js-jquery.svg)](https://gitter.im/UdashFramework/scala-js-jquery?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) programs.
## Usage
Add the following dependency to your SBT build:
```scala
libraryDependencies += "io.udash" %%% "udash-jquery" % "3.3.0"
```then import the jQuery package:
```scala
import io.udash.wrappers.jquery._
```Since version `3.0.4` the wrapper targets SJS 1.x series and supports JS dependencies managed by
by [scalajs-bundler](https://github.com/scalacenter/scalajs-bundler) or [sbt-jsdependencies
](https://github.com/scala-js/jsdependencies)
## Examples
```scala
import io.udash.wrappers.jquery._jQ("#elementId")
.hide(AnimationOptions(
duration = Some(3000),
easing = Some(EasingFunction.linear)
))
.show(1500, EasingFunction.swing)
``````scala
import io.udash.wrappers.jquery._val element: JQuery = jQ("#id")
element.text("Text content")
element.attr("example-attr", "value")
element.attr("example-attr") match {
case Some(value) => println(s"Attribute value: $value")
case None => println("Attribute not found!")
}
``````scala
import io.udash.wrappers.jquery._val callbacks = jQ.callbacks[js.Function1[(Int, Int), js.Any], (Int, Int)]()
callbacks.add((t: (Int, Int)) => {
val (a, b) = t
jQ("#plus").append(li(s"$a + $b = ${a+b}").render)
})
callbacks.add((t: (Int, Int)) => {
val (a, b) = t
jQ("#minus").append(li(s"$a - $b = ${a-b}").render)
})
callbacks.add((t: (Int, Int)) => {
val (a, b) = t
jQ("#mul").append(li(s"$a * $b = ${a*b}").render)
})
callbacks.add((t: (Int, Int)) => {
val (a, b) = t
jQ("#div").append(li(s"$a / $b = ${a/b}").render)
})callbacks.fire(1, 1)
callbacks.fire(3, 3)
callbacks.fire(7, 4)callbacks.disable()
callbacks.fire(1, 2)
```