994b52394e2e977453b96b42c3b39612d89917e8
[emels.git] / emels / static / admin / js / change_form.js
1 /*global showAddAnotherPopup, showRelatedObjectLookupPopup showRelatedObjectPopup updateRelatedObjectLinks*/
2
3 (function($) {
4     'use strict';
5     $(document).ready(function() {
6         var modelName = $('#django-admin-form-add-constants').data('modelName');
7         $('.add-another').click(function(e) {
8             e.preventDefault();
9             var event = $.Event('django:add-another-related');
10             $(this).trigger(event);
11             if (!event.isDefaultPrevented()) {
12                 showAddAnotherPopup(this);
13             }
14         });
15
16         if (modelName) {
17             $('form#' + modelName + '_form :input:visible:enabled:first').focus();
18         }
19     });
20 })(django.jQuery);