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

load more functionality for nested child #625

Open
hafizabdulbasit opened this issue Jul 29, 2022 · 6 comments
Open

load more functionality for nested child #625

hafizabdulbasit opened this issue Jul 29, 2022 · 6 comments

Comments

@hafizabdulbasit
Copy link

I am facing an issue with loading the edit page where the parent has thousands of nested children it breaks the page while rendering the HTML.
the query is already optimized and the server does not take a lot of time to process the records it's the HTML that is rendered multiple times and makes the web page irresponsive.
the main question is can we add something like load more which fetches the data with ajax and appends it to the parent so that the page doesn't get broken?

@nathanvda anything you can suggest or direct me to something if this is already done?

@nathanvda
Copy link
Owner

Not sure what you are asking here? Rendering 1000s of nested children will always take time. That is why in general we use pagination? Or do you believe cocoon is making the rendering extra slow? Which could be the case if you would render the link_to_add_association in each child's partial. But it is hard to comment on that without knowing how your view looks.

With regards to pagination there are some popular gems, off the top of my head I have used will_paginate, kaminari and recently pagy.

@hafizabdulbasit
Copy link
Author

@nathanvda thanks for the quick response.
yes, am asking something like pagination. but for the edit page we can not use pagination I guess. because the form is rendered and in the form, we can not render pagination.

here is the association used in my case hope you can see this meaning full.

Models => Assessment, Step, Item

my form is rendered with the following associations

assessment has many steps
a step has many items

so in my case, I have Parent as Assessment which has 5 steps and each step has 400 items all rendered through cocoon as nested form.

@hafizabdulbasit
Copy link
Author

hafizabdulbasit commented Jul 29, 2022

@nathanvda here is what my view looks like. I have loaded very short record because it takes to much time for which record am facing a page unresponsive issue. for more details am mentioning that the form with green left border is in thousands due to which browser gets an unresponsive error.
edit form

@nathanvda
Copy link
Owner

I am sorry, you are right. Cocoon's intention is to edit a single form with all it's nested children (and then their nested children etc.etc.) in one go. This of course does not make a lot of sense if you have 1000's of children (and their nested children). So I think in this particular case cocoon (or the 1-form approach) is not the best.

@hafizabdulbasit
Copy link
Author

@nathanvda yes exactly but is there any possibility that we add a limit for nested children that children for the given limit should be rendered via page load and then jquery should append the rest of the records in the background or something better to reduce the page load?

it would be very helpful if there is any already solution or any direction for me to so I can change or add something :)

@alex223125
Copy link

@hafizabdulbasit have you found any solution? I kinda have very similar situation. Rendering takes 18121ms,
Completed 200 OK in 18121ms (Views: 15228.9ms | ActiveRecord: 22.2ms | Allocations: 1749457)
I have nested form with recursion inside of it, but at the beginning I'm loading only 10-15 forms, not more. Wonder if there are any ways of optimization for

link_to_add_association

method.

For example if it will make request to backed for template to put instead of loading it in new form during entity creation?

@nathanvda any thoughts would be very welcome thumb up thumb up thumb up smile

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

No branches or pull requests

3 participants