fire a command event on checkboxes if persist_helper makes them checked. This handle...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Sep 2009 03:18:12 +0000 (03:18 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Sep 2009 03:18:12 +0000 (03:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14017 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js

index 56d7e59..0ab8fef 100644 (file)
                     dump('persist_helper: retrieving key = ' + key + ' value = ' + value + ' for ' + nodes[i].nodeName + '\n');
                     if (value) nodes[i].setAttribute( attribute_list[j], value );
                 }
-                if (nodes[i].nodeName == 'checkbox' && attribute_list.indexOf('checked') > -1) nodes[i].addEventListener(
-                    'command',
-                    function(bk) {
-                        return function(ev) {
-                            try {
-                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                var key = bk + 'checked';
-                                var value = ev.target.checked;
-                                ev.target.setAttribute( 'checked', value );
-                                prefs.setCharPref( key, value );
-                                dump('persist_helper: setting key = ' +  key + ' value = ' + value + ' for checkbox\n');
-                            } catch(E) {
-                                alert('Error in persist_helper(), checkbox command event listener: ' + E);
-                            }
-                        };
-                    }(base_key), 
-                    false
-                );
+                if (nodes[i].nodeName == 'checkbox' && attribute_list.indexOf('checked') > -1) {
+                    var evt = document.createEvent("Events");
+                    evt.initEvent( 'command', true, true );
+                    nodes[i].dispatchEvent(evt);
+                    nodes[i].addEventListener(
+                        'command',
+                        function(bk) {
+                            return function(ev) {
+                                try {
+                                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                    var key = bk + 'checked';
+                                    var value = ev.target.checked;
+                                    ev.target.setAttribute( 'checked', value );
+                                    prefs.setCharPref( key, value );
+                                    dump('persist_helper: setting key = ' +  key + ' value = ' + value + ' for checkbox\n');
+                                } catch(E) {
+                                    alert('Error in persist_helper(), checkbox command event listener: ' + E);
+                                }
+                            };
+                        }(base_key), 
+                        false
+                    );
+                }
                 // TODO: Need to add event listeners for window resizing, splitter repositioning, grippy state, etc.
             }
         } catch(E) {