Ticket #3202: SelectBox.js.patch

File SelectBox.js.patch, 1.3 KB (added by anonymous, 9 years ago)

Patch to SelectBox.js

  • django/contrib/admin/media/js/SelectBox.js

     
    1111    },
    1212    redisplay: function(id) {
    1313        // Repopulate HTML select box from cache
     14       // Remove the box from the DOM, manipulate it, then insert again
     15       // (offline DOM manipulation = better performance)
    1416        var box = document.getElementById(id);
     17       var parent = box.parentNode;
     18       var nextSibling = box.nextSibling; // remember where the node was
     19       parent.removeChild(box);
    1520        box.options.length = 0; // clear all options
    16         for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) {
    17             var node = SelectBox.cache[id][i];
     21       var cache = SelectBox.cache[id];
     22        for (var i = 0, j = cache.length; i < j; i++) {
     23            var node = cache[i];
    1824            if (node.displayed) {
    1925                box.options[box.options.length] = new Option(node.text, node.value, false, false);
    2026            }
    2127        }
     28       parent.insertBefore(box,nextSibling); // insert back in place
    2229    },
    2330    filter: function(id, text) {
    2431        // Redisplay the HTML select box, displaying only the choices containing ALL
Back to Top