Fixed #14193: prepopulated_fields javascript now concatenates in correct order. Thanks to bmihelac for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14122 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
941318fcee
commit
c236d5e44d
|
@ -4,7 +4,7 @@
|
|||
Depends on urlify.js
|
||||
Populates a selected field with the values of the dependent fields,
|
||||
URLifies and shortens the string.
|
||||
dependencies - selected jQuery object of dependent fields
|
||||
dependencies - array of dependent fields id's
|
||||
maxLength - maximum length of the URLify'd string
|
||||
*/
|
||||
return this.each(function() {
|
||||
|
@ -20,15 +20,15 @@
|
|||
if (field.data('_changed') == true) return;
|
||||
|
||||
var values = [];
|
||||
dependencies.each(function() {
|
||||
if ($(this).val().length > 0) {
|
||||
values.push($(this).val());
|
||||
}
|
||||
});
|
||||
$.each(dependencies, function(i, field) {
|
||||
if ($(field).val().length > 0) {
|
||||
values.push($(field).val());
|
||||
}
|
||||
})
|
||||
field.val(URLify(values.join(' '), maxLength));
|
||||
};
|
||||
|
||||
dependencies.keyup(populate).change(populate).focus(populate);
|
||||
$(dependencies.join(',')).keyup(populate).change(populate).focus(populate);
|
||||
});
|
||||
};
|
||||
})(django.jQuery);
|
||||
|
|
|
@ -1 +1 @@
|
|||
(function(b){b.fn.prepopulate=function(d,f){return this.each(function(){var a=b(this);a.data("_changed",false);a.change(function(){a.data("_changed",true)});var c=function(){if(a.data("_changed")!=true){var e=[];d.each(function(){b(this).val().length>0&&e.push(b(this).val())});a.val(URLify(e.join(" "),f))}};d.keyup(c).change(c).focus(c)})}})(django.jQuery);
|
||||
(function(a){a.fn.prepopulate=function(d,g){return this.each(function(){var b=a(this);b.data("_changed",false);b.change(function(){b.data("_changed",true)});var c=function(){if(b.data("_changed")!=true){var e=[];a.each(d,function(h,f){a(f).val().length>0&&e.push(a(f).val())});b.val(URLify(e.join(" "),g))}};a(d.join(",")).keyup(c).change(c).focus(c)})}})(django.jQuery);
|
|
@ -53,7 +53,10 @@
|
|||
var field = $(this);
|
||||
var input = field.find('input, select, textarea');
|
||||
var dependency_list = input.data('dependency_list') || [];
|
||||
var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
|
||||
var dependencies = [];
|
||||
$.each(dependency_list, function(i, field_name) {
|
||||
dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
|
||||
});
|
||||
if (dependencies.length) {
|
||||
input.prepopulate(dependencies, input.attr('maxlength'));
|
||||
}
|
||||
|
|
|
@ -99,7 +99,10 @@
|
|||
var field = $(this);
|
||||
var input = field.find('input, select, textarea');
|
||||
var dependency_list = input.data('dependency_list') || [];
|
||||
var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
|
||||
var dependencies = [];
|
||||
$.each(dependency_list, function(i, field_name) {
|
||||
dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
|
||||
});
|
||||
if (dependencies.length) {
|
||||
input.prepopulate(dependencies, input.attr('maxlength'));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
$('.empty-form .{{ field.field.name }}').addClass('prepopulated_field');
|
||||
$(field.id).data('dependency_list', field['dependency_list'])
|
||||
.prepopulate($(field['dependency_ids'].join(',')), field.maxLength);
|
||||
.prepopulate(field['dependency_ids'], field.maxLength);
|
||||
{% endfor %}
|
||||
})(django.jQuery);
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue