Created
June 28, 2011 17:13
-
-
Save hughsaunders/1051630 to your computer and use it in GitHub Desktop.
Django Admin Template Override for adding edit popups to foreign key fields.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%extends "admin/base.html" %} | |
{% block extrahead %} | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$('.add-another').each(function(i,o){ | |
select_obj=$(o).parent().find('select')[0]; | |
item_id=select_obj.options[select_obj.selectedIndex].value; | |
edit_url=o.href.replace('add',item_id)+"?_popup=1"; | |
$(this).after('<span> </span><a class="edit-popup" ' | |
+'href="'+edit_url+'"><img src="/static/admin/img/admin/' | |
+'icon_changelink.gif"/></a>') | |
}) | |
$('.edit-popup').click(function(event){ | |
win=window.open(this.href,'Edit Window', | |
'height=500,width=800,resizable=yes,scrollbars=yes') | |
win.focus() | |
event.preventDefault() | |
}) | |
}); | |
</script> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
\ doesn't work as a line continuation character in JS.