How to get clicked element text trough javascript's event.target.value
?.
I found this knockoutjs example and want to port it to Dukescript.
Here's my try:
HTML
<div class='liveExample'>
<h2 class="outmodel" data-bind="value: 'A', click: myFunction">Aaaaa</h2>
<h2 class="outmodel" data-bind="value: 'B', click: myFunction">Bbbbb</h2>
<h2 class="outmodel" data-bind="value: 'C', click: myFunction">Ccccc</h2>
<hr />
<h1 data-bind="text: say"></h1>
</div>
Java:
package dew.demo.ko4j;
import net.java.html.json.*;
import net.java.html.js.*;
@Model(className="Hello", properties={
@Property(name="say", type=String.class)
})
final class HelloViaKO {
@Function public static void myFunction(Hello model){
model.setSay(getTextValue());
}
@JavaScriptBody(args={}, body = "return event.target.value;")
private static native String getTextValue();
static {
Hello model = new Hello("Hello World!");
model.applyBindings();
}
}
And you can see it on this Fiddle, if you look at the console appears the message
java.lang.Throwable: ReferenceError: event is not defined
since java.awt.Event is nor present how can we reference the event like in this.myFunction = function (data, event)
?