Ticket #12713: fire_onchange_event_after_add_new_option.diff

File fire_onchange_event_after_add_new_option.diff, 1.5 KB (added by mishaaq, 5 years ago)

first patch

  • django-fire_onchange_event_with_select/django/contrib/admin/media/js/admin/RelatedObjectLookups.js

     
    1313
    1414// IE doesn't accept periods or dashes in the window name, but the element IDs
    1515// we use to generate popup window names may contain them, therefore we map them
    16 // to allowed characters in a reversible way so that we can locate the correct 
     16// to allowed characters in a reversible way so that we can locate the correct
    1717// element when the popup window is dismissed.
    1818function id_to_windowname(text) {
    1919    text = text.replace(/\./g, '__dot__');
     
    5555function showAddAnotherPopup(triggeringLink) {
    5656    var name = triggeringLink.id.replace(/^add_/, '');
    5757    name = id_to_windowname(name);
    58     href = triggeringLink.href
     58    href = triggeringLink.href;
    5959    if (href.indexOf('?') == -1) {
    6060        href += '?_popup=1';
    6161    } else {
     
    9393        SelectBox.redisplay(toId);
    9494    }
    9595    win.close();
     96    if(elem.fireEvent) {
     97        // for IE
     98        elem.fireEvent('onchange');
     99    }
     100    else {
     101        // for gecko based and others
     102        var evt = document.createEvent('HTMLEvents');
     103        evt.initEvent('change', true, true);
     104        elem.dispatchEvent(evt);
     105    }
    96106}
Back to Top