From 41fbf09c2b2f24e18a3277efa183fdb3f140956a Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 22 Mar 2018 20:20:12 +0100 Subject: RichTextInput fix for Firefox --- .../kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin/pl/treksoft') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt index 4c3d09a5..35418534 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt @@ -82,9 +82,10 @@ open class RichTextInput(value: String? = null, classes: Set = setOf()) } this.getElementJQuery()?.on("trix-initialize", { _, _ -> trixId = this.getElementJQuery()?.attr("trix-id") - if (trixId!=null) { + if (trixId != null) { value?.let { - this.getElement().asDynamic().editor.loadHTML(it) + if (this.getElement().asDynamic().editor != undefined) + this.getElement().asDynamic().editor.loadHTML(it) } } }) @@ -102,9 +103,11 @@ open class RichTextInput(value: String? = null, classes: Set = setOf()) val v = document.getElementById("trix-input-$trixId")?.let { jQuery(it).`val`() as String? } if (value != v) { val editor = this.getElement().asDynamic().editor - value?.let { - editor.loadHTML(it) - } ?: editor.loadHTML("") + if (editor != undefined) { + value?.let { + editor.loadHTML(it) + } ?: editor.loadHTML("") + } } } -- cgit