MCPcopy
hub / github.com/django/django / updateElementIndex

Function updateElementIndex

django/contrib/admin/static/admin/js/inlines.js:25–40  ·  view source on GitHub ↗
(el, prefix, ndx)

Source from the content-addressed store, hash-verified

23 const $this = $(this);
24 const $parent = $this.parent();
25 const updateElementIndex = function (el, prefix, ndx) {
26 const id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))");
27 const replacement = prefix + "-" + ndx;
28 if ($(el).prop("for")) {
29 $(el).prop(
30 "for",
31 $(el).prop("for").replace(id_regex, replacement),
32 );
33 }
34 if (el.id) {
35 el.id = el.id.replace(id_regex, replacement);
36 }
37 if (el.name) {
38 el.name = el.name.replace(id_regex, replacement);
39 }
40 };
41 const totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").prop(
42 "autocomplete",
43 "off",

Callers 3

addInlineClickHandlerFunction · 0.85
updateElementCallbackFunction · 0.85
inlineDeleteHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected