diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-01-20 14:22:31 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-01-20 14:22:31 +0100 |
commit | 2d8dcf194b83c39a1c3628dc207dda3bcc5652f0 (patch) | |
tree | ffafb7de0fb88e5e7aa1533818a85a695915bdc2 /kvision-modules | |
parent | 36faf5081ec2f83fe75a3b56f5887ce3c6197cc4 (diff) | |
download | kvision-2d8dcf194b83c39a1c3628dc207dda3bcc5652f0.tar.gz kvision-2d8dcf194b83c39a1c3628dc207dda3bcc5652f0.tar.bz2 kvision-2d8dcf194b83c39a1c3628dc207dda3bcc5652f0.zip |
Add "tabChange" event for TabPanel container2.9.0
Diffstat (limited to 'kvision-modules')
-rw-r--r-- | kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt | 11 |
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 } |