-
-
Save jtulach/a083ada2ddd2a5ed3ee6 to your computer and use it in GitHub Desktop.
Hello World via Knockout4Java weird bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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