docs: changed js for ajax get_pair

remotes/origin/mitri4
Andrey 9 years ago
parent f7d75c235c
commit d66663e0c3
  1. 25
      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')
$other_input.val(data['val']);
$this.css('color', 'black')
}
$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();

Loading…
Cancel
Save