aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-10-28 23:45:26 +0200
committerRobert Jaros <rjaros@finn.pl>2017-10-28 23:45:26 +0200
commit06f297d68887c7934e66d2c757abc8bf619df66a (patch)
treea828eec09f0bdc99b0f3fd45972b8cead37fbdec /src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
parent6b13b8909a302b0f0f2155b81b83cd5ab4d7a046 (diff)
downloadkvision-06f297d68887c7934e66d2c757abc8bf619df66a.tar.gz
kvision-06f297d68887c7934e66d2c757abc8bf619df66a.tar.bz2
kvision-06f297d68887c7934e66d2c757abc8bf619df66a.zip
Databinding components
Event handlers refactoring
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
index 017e7fef..82846012 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
@@ -1,16 +1,25 @@
package pl.treksoft.kvision.form
-import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.snabbdom.StringBoolPair
import pl.treksoft.kvision.snabbdom.StringPair
abstract class AbstractTextInput(placeholder: String? = null,
- override var value: String? = null, name: String? = null, maxlength: Int? = null,
- disabled: Boolean = false, id: String? = null,
- classes: Set<String> = setOf()) : Widget(classes + "form-control"), StringFormField {
+ override var value: String? = null, name: String? = null, maxlength: Int? = null,
+ disabled: Boolean = false, id: String? = null,
+ classes: Set<String> = setOf()) : Widget(classes + "form-control"), StringFormField {
init {
this.id = id
+ this.setInternalEventListener {
+ input = {
+ val v = getElementJQuery()?.`val`() as String?
+ if (v != null && v.isNotEmpty()) {
+ value = v
+ } else {
+ value = null
+ }
+ }
+ }
}
@Suppress("LeakingThis")
@@ -90,15 +99,4 @@ abstract class AbstractTextInput(placeholder: String? = null,
}
return sn
}
-
- override fun afterInsert(node: VNode) {
- this.getElementJQuery()?.on("input", { _, _ ->
- val v = getElementJQuery()?.`val`() as String?
- if (v != null && v.isNotEmpty()) {
- value = v
- } else {
- value = null
- }
- })
- }
}