Make hyperlinks for labels of raw_id_fields (jQuery)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{% block extrahead %}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
    jQuery(function($) {
        // Make hyperlinks for labels of raw_id_fields
        $('a.related-lookup').each(function() {
            var td = $(this).parent();
            var id = $('input', td).val();
            var url = $(this).attr('href').split('?')[0] + id + '/';
            $('strong', td).wrap('<a href="' + url + '"></a>');
        });
    });
//]]>
</script>
{% endblock %}

More like this

  1. Hyperlink read-only ForeignKey objects in admin to their change pages by strangefeatures 2 years, 3 months ago
  2. Link raw_id_fields (both ForeignKeys and ManyToManyFields) to their change pages by EmilStenstrom 3 years, 6 months ago
  3. Admin list_display Ajax by whiteinge 6 years, 2 months ago
  4. "Save and Continue" keyboard command for admin, with autoscroll by jcushman 4 years, 3 months ago
  5. Radio widget with labels after inputs by avsd 1 year, 9 months ago

Comments

(Forgotten your password?)