manuelp22
11/03/2016, 8:43 PMmanuelp22
11/03/2016, 8:43 PMmanuelp22
11/03/2016, 8:43 PMkonsoletyper
11/03/2016, 8:47 PMalert
function in Kotlin?konsoletyper
11/03/2016, 8:49 PMalert
is defined: https://github.com/JetBrains/kotlin/blob/master/js/js.libraries/src/generated/org.w3c.dom.kt
(actually, it's generated from IDL)konsoletyper
11/03/2016, 8:51 PMkonsoletyper
11/03/2016, 8:52 PMimport kotlin.browser.*
fun main(args: Array<String>) {
window.alert("Hello, world!")
}
konsoletyper
11/03/2016, 8:53 PM@native fun alert(message: Any?) {}
konsoletyper
11/03/2016, 8:53 PMjs("window").alert("Hello, world!")
manuelp22
11/03/2016, 9:44 PMmanuelp22
11/03/2016, 9:47 PMmanuelp22
11/03/2016, 9:48 PM<a onclick="KotlinProject.testMethod()" href="#">
oluwasayo
11/03/2016, 10:30 PMmanuelp22
11/04/2016, 12:13 PM<button onclick="SampleProject.testMethod()" href="#">SUBMIT</button>
2) But when calling a Kotlin function with a parameter from Javascript:
Like this
<button onclick="SampleProject.testMethodWithParam(25)" href="#">SUBMIT</button>
I get the following error for that line
TypeError: SampleProject.testMethodWithParam is not a function
Main.kt is:
// this works
public fun testMethod(){
println("testMethod triggered")
}
// this does not work
public fun testMethodWithParam(something: Int){
println("testMethodWithParam triggered")
}
kirillrakhman
11/04/2016, 12:16 PMmanuelp22
11/04/2016, 12:18 PMtestMethod: function () {
Kotlin.println('testMethod triggered');
},
testMethodWithParam_za3lpa$: function (something) {
Kotlin.println('testMethodWithParam triggered');
},
manuelp22
11/04/2016, 12:19 PM_za3lpa$
manuelp22
11/04/2016, 12:20 PMkirillrakhman
11/04/2016, 12:20 PMmanuelp22
11/04/2016, 12:20 PMkirillrakhman
11/04/2016, 12:21 PM@JsName("testMethodWithParam")
?kirillrakhman
11/04/2016, 12:21 PMkirillrakhman
11/04/2016, 12:22 PMmanuelp22
11/04/2016, 12:22 PMkirillrakhman
11/04/2016, 12:23 PMkirillrakhman
11/04/2016, 12:23 PMmanuelp22
11/04/2016, 12:23 PMmanuelp22
11/04/2016, 12:32 PMkonsoletyper
11/04/2016, 12:49 PMpdvrieze
11/09/2016, 11:53 AM