This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
<!-- ACTUAL CHANGES BEGIN HERE: -->
<changes>
<change id="bindings-function">
<api name="ko"/>
<summary>Introducing Bindings.function(String name)</summary>
<version major="1" minor="1" />
<date day="11" month="3" year="2015"/>
<author login="rsvitanic"/>
<compatibility addition="yes" modification="no" semantic="compatible" source="compatible" binary="compatible"/>
<description>
<p>
Added method Bindings.function(String name) which generates an empty function property.
</p>
</description>
<issue number="251075"/>
</change>
<change id="branding.token">
<summary>Introduced</summary>
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.api.knockout
OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/knockout/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
OpenIDE-Module-Specification-Version: 1.1
AutoUpdate-Show-In-Client: false
return this;
}
/**
* Generates a function (empty) into the JSON class.
*
* @param name name of variable (must be valid JavaScript identifier)
* @return this object
* @since 1.1
*/
public final Bindings function(String name) {
addProp(name, false, "function() {}");
final String generate() {
StringBuilder sb = new StringBuilder();
//sb.append("(function() {\n");
assertEquals(eng.eval("ko.value.currentTweets[0].from_user_id"), 0d, "Boolean values are set to true");
@Test
public void generateModelWithFunctions() throws Exception {
Bindings myModel = Bindings.create("MyModel").
function("myFunc1").
function("func2");
String txt = myModel.generate();
assertValidJS(txt);
assertNotNull(eng.eval("ko"));
assertNotNull(eng.eval("ko.value"));
assertNotNull(eng.eval("ko.value.myFunc1"));
assertNotNull(eng.eval("ko.value.func2"));
private void assertValidJS(String txt) {
assertNotNull(txt, "We have some script");
try {