All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.ui.binder.SelectBoolean.scala Maven / Gradle / Ivy

There is a newer version: 0.10.3
Show newest version
package org.hyperscala.ui.binder

import org.hyperscala.html._
import org.hyperscala.ui.dynamic.Binder
import language.reflectiveCalls
import org.hyperscala.realtime.RealtimeEvent

/**
 * @author Matt Hicks 
 */
class SelectBoolean(trueString: String = "Yes", falseString: String = "No") extends Binder[tag.Select, Boolean] {
  def bind(select: tag.Select) = {
    select.changeEvent := RealtimeEvent()
    select.contents.clear()
    select.contents += new tag.Option(value = "true", content = trueString, selected = valueProperty())
    select.contents += new tag.Option(value = "false", content = falseString, selected = !valueProperty())

    select.value.change.on {
      case evt => {
        val v = select.value()
        valueProperty := v.toBoolean
      }
    }

    valueProperty.change.on {
      case evt => select.value := valueProperty().toString
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy