Ticket #1404: trunk-admin_popup_selectfilter_fix.diff

File trunk-admin_popup_selectfilter_fix.diff, 1.2 KB (added by Tom Tobin <korpios@…>, 19 years ago)

patch against r2408 of trunk to fix admin popup breakage with m2m fields and filter_interface

  • contrib/admin/media/js/admin/RelatedObjectLookups.js

     
    2929function dismissAddAnotherPopup(win, newId, newRepr) {
    3030    var name = win.name.replace(/___/g, '.')
    3131    var elem = document.getElementById(name);
    32     if (elem.nodeName == 'SELECT') {
     32    if (elem) {
     33        if (elem.nodeName == 'SELECT') {
     34            var o = new Option(newRepr, newId);
     35            elem.options[elem.options.length] = o
     36            elem.selectedIndex = elem.length - 1;
     37        } else if (elem.nodeName == 'INPUT') {
     38            elem.value = newId;
     39        }
     40    } else {
     41        var toId = name + "_to";
     42        elem = document.getElementById(toId);
    3343        var o = new Option(newRepr, newId);
    34         elem.options[elem.options.length] = o
    35         elem.selectedIndex = elem.length - 1;
    36     } else if (elem.nodeName == 'INPUT') {
    37         elem.value = newId;
     44        SelectBox.add_to_cache(toId, o);
     45        SelectBox.redisplay(toId);
    3846    }
    3947    win.close();
    4048}
Back to Top