"Save and Continue" keyboard command for admin, with autoscroll

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
In a change_form template, such as templates/admin/myapp/change_form.html:

{% extends "admin/change_form.html" %}

{% block extrahead %}
	{{ block.super }}
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
    <script src="{{MEDIA_URL}}js/jquery.cookie.js" type="text/javascript"></script>
    <script src="{{MEDIA_URL}}js/shortcut.js" type="text/javascript"></script>
    <script type="text/javascript">
		$(function(){
			setTimeout(function(){
					$(window).scrollTop($.cookie('django_admin_scroll'));
					$.cookie('django_admin_scroll', 0);
				}, 100);
		});
		function save_and_continue(){
			$.cookie('django_admin_scroll',$(window).scrollTop());
			$('input[name="_continue"]').click()
		}
		shortcut.add("Meta+S", save_and_continue);
		shortcut.add("Ctrl+S", save_and_continue);
    </script>
{% endblock %}

More like this

  1. FieldsetForm by Ciantic 7 years ago
  2. Django using admin horizontal filter in forms by crodjer 2 years, 10 months ago
  3. Admin Input Field Character Count via jQuery by joshman 5 years, 4 months ago
  4. Make hyperlinks for labels of raw_id_fields (jQuery) by ramen 4 years, 3 months ago
  5. Confirm alert if the user navigates away without saving changes by mrazzari 4 years, 9 months ago

Comments

(Forgotten your password?)