Call JQuery Eventhandler

How can i call a member function for a jQuery Eventhandler ?

import jquery.jq

class Test
println(“Init Test”)

fun myReady(){
println(“Ready Callback!”)

I got following Error:

Uncaught TypeError: this$Test.myReady is not a function

There are too many ways and setups to make this work. I can’t tell you what is wrong in your code, because I don’t know what your setup is? Do you bind jQuery as a library via @JsModule/external?

In my HTML the jQuery is loaded via Script, in Kotlin i use the Standard Library.

What module loading library are you using in JavaScript? Or are you using no module loader?

I use no Module Loader. The Document ready Event is called. If i use a println(“”) directly it works, but it looks to me that the “this” is not available.

This works: jq().ready{ println(“Callback called”)}

but not calling a Member function.

Where and how do you create an object of your Test class?

In HTML Java Script:

$(document).ready(function ()
console.log(“document loaded”);
let test = Portal.Test();

Got it :joy:

I have instantiate the Test class with new Test() in my Script. So i was operation on the Class itself instead of an Instance.

Sorry for that :sleepy: