mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-22 05:12:22 -06:00
Closes #3810: Preserve slug value when editing existing objects
This commit is contained in:
@@ -42,17 +42,23 @@ $(document).ready(function() {
|
||||
return s.substring(0, num_chars); // Trim to first num_chars chars
|
||||
}
|
||||
var slug_field = $('#id_slug');
|
||||
slug_field.change(function() {
|
||||
$(this).attr('_changed', true);
|
||||
});
|
||||
if (slug_field) {
|
||||
var slug_source = $('#id_' + slug_field.attr('slug-source'));
|
||||
var slug_length = slug_field.attr('maxlength');
|
||||
if (slug_field[0].value) {
|
||||
slug_field.attr('_changed', true);
|
||||
}
|
||||
slug_field.change(function() {
|
||||
$(this).attr('_changed', true);
|
||||
});
|
||||
slug_source.on('keyup change', function() {
|
||||
if (slug_field && !slug_field.attr('_changed')) {
|
||||
slug_field.val(slugify($(this).val(), (slug_length ? slug_length : 50)));
|
||||
}
|
||||
})
|
||||
});
|
||||
$('button.reslugify').click(function() {
|
||||
slug_field.val(slugify(slug_source.val(), (slug_length ? slug_length : 50)));
|
||||
});
|
||||
}
|
||||
|
||||
// Bulk edit nullification
|
||||
|
||||
Reference in New Issue
Block a user