Closed prohfessor closed 3 years ago
i found how to embed javascript - execute()
Hi @prohfessor. Your question is a bit chaotic so I'll try my best to answer each point as I understand your problem (and I'm not sure if I do all the way).
1. Here I'm not sure what is the problem. In my pet project I'm using setAttributeRaw
this way:
div(fomantic.item).setAttributeRaw("data-value", area.id).text(area.name)
and it works all right. Produces following HTML:
<div id="Ke" class="item selected" data-value="261f5fb6-e4c9-4945-a92a-2998ffdc8004">
Sample Item
</div>
Could you provide some more details on your particular problem? What is the exact output you are getting and what would you like to have instead.
2. While you can change the value if it's global with simple execute("ttt = 'new value'")
you shouldn't have global variables in the first place 🙂 What is the reason you want to do this? Maybe there is another way to achieve the same effect?
3. This should work:
doc.head.new {
element("script", mapOf(
"src" to "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js",
"integrity" to "sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==",
"crossorigin" to ""
))
}
1. setAttributeRaw changes the quotation marks to a " in front and the end of the text
works correctly on my side.
a().setAttributeRaw("id", "newid")
gives -
<a id="newid" href="#"></a>
maybe the issue is in something else, your id might contain some unsupported character maybe or you are escaping them somehow.
closing as can't reproduce and inactivity.
Hello! Recently I began to study Kotlin and KWeb and ran into a couple of problems:
a().setAttribute("href", "http://kweb.io")
<a>
element and set it to<a href="http://kweb.io/">
.But when I try to change, for example 'id' a().setAttributeRaw("id", "newid") I get: id=" newid" How can I change correctly 'id'? I do that way: a(attributes = mapOf("id" to "newid"))
Can i change the variable 'ttt' in javascript from KWeb?: element("ttt2").innerHTML( """
"""
How to insert in header link to css and js file? Now I insert something like this: