MCPcopy
hub / github.com/django/django / addInlineDeleteButton

Function addInlineDeleteButton

django/contrib/admin/static/admin/js/inlines.js:136–173  ·  view source on GitHub ↗
(row)

Source from the content-addressed store, hash-verified

134 * (When saved, it is replaced with a "Delete" checkbox.)
135 */
136 const addInlineDeleteButton = function (row) {
137 if (row.is("tr")) {
138 // If the forms are laid out in table rows, insert
139 // the remove button into the last table cell:
140 row.children(":last").append(
141 '<div><a role="button" class="' +
142 options.deleteCssClass +
143 '" href="#">' +
144 options.deleteText +
145 "</a></div>",
146 );
147 } else if (row.is("ul") || row.is("ol")) {
148 // If they're laid out as an ordered/unordered list,
149 // insert an <li> after the last list item:
150 row.append(
151 '<li><a role="button" class="' +
152 options.deleteCssClass +
153 '" href="#">' +
154 options.deleteText +
155 "</a></li>",
156 );
157 } else {
158 // Otherwise, just insert the remove button as the
159 // last child element of the form's container:
160 row.children(":first").append(
161 '<span><a role="button" class="' +
162 options.deleteCssClass +
163 '" href="#">' +
164 options.deleteText +
165 "</a></span>",
166 );
167 }
168 // Add delete handler for each row.
169 row.find("a." + options.deleteCssClass).on(
170 "click",
171 inlineDeleteHandler.bind(this),
172 );
173 };
174
175 const inlineDeleteHandler = function (e1) {
176 e1.preventDefault();

Callers 2

addInlineClickHandlerFunction · 0.85
inlines.jsFile · 0.85

Calls 2

appendMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected