change the way domids are built for checkboxes in a hazelnut - new method Plugin...
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 2 Oct 2013 15:15:40 +0000 (17:15 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 2 Oct 2013 15:15:40 +0000 (17:15 +0200)
manifold/static/js/plugin.js
plugins/hazelnut/static/js/hazelnut.js

index f392961..3745f64 100644 (file)
@@ -192,6 +192,19 @@ var Plugin = Class.extend({
         return key_field + manifold.separator + unfold.escape_id(value).replace(/\\/g, '');
     },
 
+    // we do not need to carry around all the nonsense about backslashing dots in hrns
+    // likewise, DOM ids do not like to have dots in them
+    // because "#foo.bar" matches an elem named foo with class bar - not an id that is foo.bar
+    // so this method gives you a valid DOMID but that cannot be 'reversed' back to retrieve an hrn or the like
+    // e.g. 
+    // input=input="ple.aluiple.host147-82-static\\.93-94-b\\.business\\.telecomitalia\\.it"
+    // > "ple.aluiple.host147-82-static\.93-94-b\.business\.telecomitalia\.it"
+    // flat_id(input)
+    // "ple-aluiple-host147-82-static-93-94-b-business-telecomitalia-it"
+    flat_id : function (id_in) {
+       return id_in.replace(/\\\./g,"-").replace(/\\/g,"-").replace(/\./g,"-");
+    },
+
     id_from_record: function(method, record) {
         var keys = manifold.metadata.get_key(method);
         if (!keys)
index 81cf1e2..c572d6a 100644 (file)
             // Prefix id with plugin_uuid
             result += "<input";
             result += " class='hazelnut-checkbox'";
-            result += " id='" + this.id('checkbox', this.id_from_key(key, value)) + "'";
+            result += " id='" + this.flat_id(this.id('checkbox', value)) + "'";
             result += " name='" + key + "'";
             result += " type='checkbox'";
             result += " autocomplete='off'";
             }
 
 
-            var checkbox_id = this.id('checkbox', this.id_from_key(this.key, key_value));
-            checkbox_id = '#' + checkbox_id.replace(/\./g, '\\.');
-
+            var checkbox_id = this.flat_id(this.id('checkbox', key_value));
+            checkbox_id = '#' + checkbox_id;
             var element = $(checkbox_id, this.table.fnGetNodes());
-
+//         messages.debug("set_checkbox checked=" + checked + " id=" + checkbox_id + " matches=" + element.length);
             element.attr('checked', checked);
         },