Last active
October 24, 2015 18:56
-
-
Save jtulach/8848505 to your computer and use it in GitHub Desktop.
Shows usage of @function callback
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> |
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment