Last active
May 26, 2016 12:57
-
-
Save ochrons/e04f3ef423b85ae41b35bc36af01552f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $FiddleDependency org.scala-js %%% scalajs-dom % 0.9.0 | |
// $FiddleDependency com.lihaoyi %%% scalatags % 0.5.4 | |
import scalatags.JsDom.all._ | |
import org.scalajs.dom | |
import fiddle.Fiddle, Fiddle.println | |
import scalajs.js | |
object ScalaFiddle extends js.JSApp { | |
def main() = { | |
// $FiddleStart | |
val textbox = input(placeholder := "message").render | |
val result = div.render | |
textbox.onkeyup = (e: dom.Event) => { | |
result.textContent = textbox.value | |
} | |
val content = div( | |
h2("Hello Scala.js"), | |
textbox, | |
result | |
) | |
println(content) | |
// $FiddleEnd | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $FiddleDependency org.scala-js %%% scalajs-dom % 0.9.0 | |
// $FiddleDependency com.lihaoyi %%% scalatags % 0.5.4 | |
import scalatags.JsDom.all._ | |
import org.scalajs.dom | |
import fiddle.Fiddle, Fiddle.println | |
import scalajs.js | |
object ScalaFiddle extends js.JSApp { | |
def main() = { | |
// $FiddleStart | |
val countries = Seq( | |
"Macau", | |
"Macedonia", | |
"Madagascar", | |
"Malawi", | |
"Malaysia", | |
"Maldives", | |
"Mali", | |
"Malta", | |
"Marshall Islands", | |
"Mauritania", | |
"Mauritius", | |
"Mexico", | |
"Micronesia", | |
"Moldova", | |
"Monaco", | |
"Mongolia", | |
"Montenegro", | |
"Morocco", | |
"Mozambique" | |
) | |
val textbox = input(placeholder := "Country").render | |
val result = div.render | |
textbox.onkeyup = (e: dom.Event) => { | |
result.innerHTML = "" | |
result.appendChild( | |
ul( | |
countries | |
.filter(c => c.toLowerCase.startsWith(textbox.value.toLowerCase)) | |
.map(t => li(t)) | |
).render | |
) | |
} | |
val content = div( | |
h2("Hello Scala.js"), | |
textbox, | |
result | |
) | |
println(content) | |
// $FiddleEnd | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment