You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jt...@apache.org on 2019/05/03 18:20:14 UTC

[netbeans-html4j] branch master updated: Use triggerEvent to notify about an index change

This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-html4j.git


The following commit(s) were added to refs/heads/master by this push:
     new b618068  Use triggerEvent to notify about an index change
b618068 is described below

commit b618068f60baee8f1811716563d7fc29e9d4ddcc
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Fri May 3 20:20:02 2019 +0200

    Use triggerEvent to notify about an index change
---
 .../src/main/java/net/java/html/json/tests/KnockoutTest.java   | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
index cc3b07f..7e07b35 100644
--- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
+++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
@@ -263,12 +263,10 @@ public final class KnockoutTest {
 
     private static String getSetSelected(int index, Object value) throws Exception {
         String s = "var index = arguments[0];\n"
-        + "var value = arguments[1];\n"
         + "var n = window.document.getElementById('input'); \n "
-        + "if (value != null) {\n"
-        + "  n.options[index].value = 'me'; \n"
-        + "  n.value = 'me'; \n"
-        + "  ko.dataFor(n.options[index]).archetype(value); // haven't found better way to trigger ko change yet \n"
+        + "if (index >= 0) {\n"
+        + "    n.options.selectedIndex = index; \n"
+        + "    ko.utils.triggerEvent(n, 'change'); \n"
         + "} \n "
         + "var op = n.options[n.selectedIndex]; \n"
         + "return op ? op.text : n.selectedIndex;\n";
@@ -310,7 +308,7 @@ public final class KnockoutTest {
             js.setArchetype(js.getArchetypes().get(1));
             js.applyBindings();
 
-            String v = getSetSelected(0, null);
+            String v = getSetSelected(-1, null);
             assertEquals("crud", v, "Second index (e.g. crud) is selected: " + v);
 
             String sel = getSetSelected(2, Models.toRaw(js.getArchetypes().get(2)));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists