[Rt-commit] rt branch, 4.2/refactor-cf-cascaded-selects-js, created. rt-4.2.1-3-g1efa282

? sunnavy sunnavy at bestpractical.com
Wed Nov 20 11:15:17 EST 2013


The branch, 4.2/refactor-cf-cascaded-selects-js has been created
        at  1efa282ad3f2a52529ccbcc38764044d0ef21c7f (commit)

- Log -----------------------------------------------------------------
commit 1efa282ad3f2a52529ccbcc38764044d0ef21c7f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Nov 21 00:10:42 2013 +0800

    use jQuery to do the remove/clone nodes for better compatibility
    
    initial reason is old code has a bug on ie<=8(see also #16629)

diff --git a/share/static/js/cascaded.js b/share/static/js/cascaded.js
index 2377a33..015e821 100644
--- a/share/static/js/cascaded.js
+++ b/share/static/js/cascaded.js
@@ -37,9 +37,7 @@ function filter_cascade_select (select, complete_select, vals, is_hierarchical)
     var children = select.childNodes;
 
     if ( complete_select ) {
-        while (select.hasChildNodes()){
-            select.removeChild(select.firstChild);
-        }
+        jQuery(select).children().remove();
 
         var complete_children = complete_select.childNodes;
 
@@ -52,12 +50,7 @@ function filter_cascade_select (select, complete_select, vals, is_hierarchical)
                 // leave this set of options empty
             } else if ( val == '' ) {
                 // no category, let's clone all node
-                for (i = 0; i < complete_children.length; i++) {
-                    if ( complete_children[i].cloneNode ) {
-                        var new_option = complete_children[i].cloneNode(true);
-                        select.appendChild(new_option);
-                    }
-                }
+                jQuery(select).append(jQuery(complete_children).clone());
                 break;
             }
             else {
@@ -80,10 +73,7 @@ function filter_cascade_select (select, complete_select, vals, is_hierarchical)
                         continue;
                     }
 
-                    if ( complete_children[i].cloneNode ) {
-                        var new_option = complete_children[i].cloneNode(true);
-                        select.appendChild(new_option);
-                    }
+                    jQuery(select).append(jQuery(complete_children[i]).clone());
                 }
 
                 if ( !cloned_empty_label )

-----------------------------------------------------------------------


More information about the rt-commit mailing list