Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra 0 doesn't work with nested inlines #151

Open
mo-dkrz opened this issue Mar 23, 2023 · 1 comment
Open

Extra 0 doesn't work with nested inlines #151

mo-dkrz opened this issue Mar 23, 2023 · 1 comment

Comments

@mo-dkrz
Copy link

mo-dkrz commented Mar 23, 2023

Dear all,
When I set extra=0, nested inlines don't work and on the other hand, I get the following error in the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
But using extra=1 all is well. I appreciate it if you give me a hint or solution regarding this issue.
Cheers,
Mo

@OskarPersson
Copy link
Owner

This seems to be a duplicate of #4, #28 and #67. I think what is said here still applies: #4 (comment)

The function that creates the new elements when clicking on "Add another ..." depends on already visible elements when it creates the new ones:

function create_nested_formset(parent_formset_prefix, next_form_id, options, add_bottom_border) {
var formsets = $(false);
// update options
// Normalize prefix to something we can rely on
var normalized_parent_formset_prefix = parent_formset_prefix.replace(/[-][0-9][-]/g, "-0-");
// Check if the form should have nested formsets
var nested_inlines = $('#' + normalized_parent_formset_prefix + "-group ." + normalized_parent_formset_prefix + "-0-nested-inline").not('.cloned');
if (!nested_inlines.length) {
nested_inlines = $('#' + normalized_parent_formset_prefix + "-group ." + normalized_parent_formset_prefix + "-nested-inline").not('.cloned');
}

Therefore since no elements exists to choose from when using extra=0, it doesn't know how to properly create the new ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants