diff --git a/project/templates/docs/stub_js.html b/project/templates/docs/stub_js.html
index 73c5cbe..51b6636 100644
--- a/project/templates/docs/stub_js.html
+++ b/project/templates/docs/stub_js.html
@@ -9,29 +9,28 @@
prefix: '{{ formset.prefix }}',
formCssClass: 'dynamic-form',
});
- var get_pair = function(model, class1, class2, name1, name2) {
- $('body').on('focusout', '.' + class1 + ' input', function() {
+
+ var get_pair = function(model, class1, class2, param1, param2) {
+ $('body').on('selectChoice change', '.' + class1 + ' input', function() {
var $this = $(this);
- var $code_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input');
- var code_input_val = $code_input.val();
+ var this_val = $this.val();
+ var $other_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input');
- $.get('/my/docs/ajax_get_pair/' + model + '/' + name1 + '/' + name2 + '/' + $this.val() + '/', function(data){
+ $.get('/my/docs/ajax_get_pair/' + model + '/' + param1 + '/' + param2 + '/' + this_val + '/', function(data) {
if (data['val']) {
- $code_input.val(data['val']);
- if (($code_input.val() != '')&&(($code_input.val() != code_input_val))) {
- $code_input.css('color', 'red')
- } else {
- $code_input.css('color', 'black')
- }
- $this.css('color', 'black');
+ $other_input.val(data['val']);
+ $this.css('color', 'black')
+ }
+ else {
+ $other_input.val('-');
+ $this.css('color', 'red')
}
});
})
}
- get_pair('Country', 'country_code', 'country_name', 'code', 'name');
+ {# model должна быть разрешена в docs.views.get_pair #}
get_pair('Country', 'country_name', 'country_code', 'name', 'code');
get_pair('Measure', 'units', 'units_kod', 'name', 'code');
- get_pair('Measure', 'units_kod', 'units', 'code', 'name');
$('#id_client').on('change', function() {
var client_id = $(this).val();
@@ -112,7 +111,7 @@
} else {
$('#fix_block').hide();
}
- $('#id_fixes').change(function(){
+ $('#id_fixes').change(function(){
$('#fix_block').toggle();
$('#id_fix_doc_num').val('');
$('#id_fix_doc_date').val('');