Skip to content
This repository has been archived by the owner on Oct 9, 2022. It is now read-only.

Commit

Permalink
Update routing.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Mar 31, 2020
1 parent 425496a commit 8930a33
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ to integrate the 404 page with the style of your overall website:
Modifying the URL
-----------------

For example:
You can obtain *and modify* the URL of the current page using [WebBrowser.url](https://github.com/kwebio/kweb-core/blob/master/src/main/kotlin/kweb/WebBrowser.kt#L98).


Expand All @@ -103,7 +103,7 @@ Here is a more realistic example:
path("/number/{num}") { params ->
val num = params.getValue("num").toInt()
a().text(num.map {"Number $it"}).on.click {
url.value++
num.value++
}
}
}
Expand All @@ -115,4 +115,6 @@ If you visit http://localhost:16097/ the URL will immediately update to http://l
without a page refresh, and you'll see a hyperlink with text "Number 1". If you click on this link
you'll see that the number increments (both in the URL and in the link text), also without a page refresh.


The line *num.value++* is worthy of additional attention. *num* is a KVar<Int>, and so it can be
incremented via its *value* property. This will cause the page URL to update, which will in-turn cause
the DOM to update to reflect the new URL. All of this is handled for you by Kweb.

0 comments on commit 8930a33

Please sign in to comment.