|
145 | 145 |
|
146 | 146 |
|
147 | 147 | // Tabular inlines ---------------------------------------------------------
|
148 |
| - $.fn.tabularFormset = function(options) { |
| 148 | + $.fn.tabularFormset = function(selector, options) { |
149 | 149 | var $rows = $(this);
|
150 | 150 | var alternatingRows = function(row) {
|
151 |
| - $($rows.selector).not(".add-row").removeClass("row1 row2") |
| 151 | + $(selector).not(".add-row").removeClass("row1 row2") |
152 | 152 | .filter(":even").addClass("row1").end()
|
153 | 153 | .filter(":odd").addClass("row2");
|
154 | 154 | };
|
|
212 | 212 | };
|
213 | 213 |
|
214 | 214 | // Stacked inlines ---------------------------------------------------------
|
215 |
| - $.fn.stackedFormset = function(options) { |
| 215 | + $.fn.stackedFormset = function(selector, options) { |
216 | 216 | var $rows = $(this);
|
217 | 217 | var updateInlineLabel = function(row) {
|
218 |
| - $($rows.selector).find(".inline_label").each(function(i) { |
| 218 | + $(selector).find(".inline_label").each(function(i) { |
219 | 219 | var count = i + 1;
|
220 | 220 | $(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
|
221 | 221 | });
|
|
281 | 281 | $(document).ready(function() {
|
282 | 282 | $(".js-inline-admin-formset").each(function() {
|
283 | 283 | var data = $(this).data(),
|
284 |
| - inlineOptions = data.inlineFormset; |
| 284 | + inlineOptions = data.inlineFormset, |
| 285 | + selector; |
285 | 286 | switch(data.inlineType) {
|
286 | 287 | case "stacked":
|
287 |
| - $(inlineOptions.name + "-group .inline-related").stackedFormset(inlineOptions.options); |
| 288 | + selector = inlineOptions.name + "-group .inline-related"; |
| 289 | + $(selector).stackedFormset(selector, inlineOptions.options); |
288 | 290 | break;
|
289 | 291 | case "tabular":
|
290 |
| - $(inlineOptions.name + "-group .tabular.inline-related tbody:first > tr").tabularFormset(inlineOptions.options); |
| 292 | + selector = inlineOptions.name + "-group .tabular.inline-related tbody:first > tr"; |
| 293 | + $(selector).tabularFormset(selector, inlineOptions.options); |
291 | 294 | break;
|
292 | 295 | }
|
293 | 296 | });
|
|
0 commit comments