Skip to content

Instantly share code, notes, and snippets.

@jtulach
Forked from javatlacati/HelloViaKO.java
Created December 15, 2015 21:59
Show Gist options
  • Save jtulach/a083ada2ddd2a5ed3ee6 to your computer and use it in GitHub Desktop.
Save jtulach/a083ada2ddd2a5ed3ee6 to your computer and use it in GitHub Desktop.
Hello World via Knockout4Java weird bug
package dew.demo.namesmodel;
import net.java.html.json.Model;
import net.java.html.json.Property;
import net.java.html.json.Function;
@Model(className="Names", properties={
@Property(name = "selectedName", type=String.class),
@Property(name = "names", type=String.class, array = true)
})
class NamesModel {
@Function static void nameSelected(Names myModel, String data) {
myModel.setSelectedName(data);
}
static {
Names pageModel = new Names(
"---", "Jarda", "Pepa", "Honza", "Jirka", "Tomáš"
);
pageModel.applyBindings();
}
}
Selected name: <span data-bind="text: selectedName"></span>
<ul data-bind="foreach: names">
<li>
<a data-bind="text: $data, click: $root.nameSelected" href="#"></a>
</li>
</ul>
<hr>
<div data-bind="with: 'hi'">
<a data-bind="text: $data,click: $root.nameSelected" href="#"></a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment