aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules/kvision-bootstrap/src/main')
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt11
1 files changed, 9 insertions, 2 deletions
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
index d75d10df..44c0a243 100644
--- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
+++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
@@ -146,6 +146,7 @@ open class TabPanel(
* @param route JavaScript route to activate given child
* @return current container
*/
+ @Suppress("UnsafeCastFromDynamic")
open fun addTab(
title: String, panel: Component, icon: String? = null,
image: ResString? = null, closable: Boolean = false, route: String? = null
@@ -181,6 +182,9 @@ open class TabPanel(
e.preventDefault()
if (route != null) {
routing.navigate(route)
+ } else {
+ e.asDynamic().data = activeIndex
+ this@TabPanel.dispatchEvent("tabChange", obj { detail = e })
}
}
}
@@ -194,8 +198,10 @@ open class TabPanel(
if (route != null) {
routing.on(
route,
- { _ -> activeIndex = this@TabPanel.content.getChildren().indexOf(childrenMap[currentIndex]) })
- .resolve()
+ { _ ->
+ activeIndex = this@TabPanel.content.getChildren().indexOf(childrenMap[currentIndex])
+ this@TabPanel.dispatchEvent("tabChange", obj { detail = obj { data = activeIndex } })
+ }).resolve()
}
return this
}
@@ -210,6 +216,7 @@ open class TabPanel(
}
content.remove(content.getChildren()[index])
activeIndex = content.activeIndex
+ this@TabPanel.dispatchEvent("tabChange", obj { detail = obj { data = activeIndex } })
return this
}