{% include "admin/edit_inline/tabular.html" %}
<script>
function set_entity_name(name, id) {
    var $ = django.jQuery;
    $.getJSON('/entity/'+ id + '/', function(data) {
      $('#label_' + name).val(data.description);
    });
}
function dismissRelatedLookupPopup(win, chosenId) {
    var name = windowname_to_id(win.name);
    var elem = document.getElementById(name);
    if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
        elem.value += ',' + chosenId;
    } else {
        document.getElementById(name).value = chosenId;
        set_entity_name(name, chosenId);
    }
    // GRAPPELLI CUSTOM: element focus
    elem.focus();
    win.close();
}
</script>
