You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's often the case that you have tabular data that you want to use a template for each row. Which means you need a partial for the initial load and reload of the main table, but also a template of the row so you can add just 1 later down the road.
Then we wouldn't have access to the parent data in the partial or the template because of the loop were inside of.
The only other alternative is to pass ../ into your partial, but then you lose the ability to each loop through your data. So that doesn't work either.
So TL;DR
You should be able to register a partial with an already compiled template
Partials should have access to the parent context
The text was updated successfully, but these errors were encountered:
It's often the case that you have tabular data that you want to use a template for each row. Which means you need a partial for the initial load and reload of the main table, but also a template of the row so you can add just 1 later down the road.
Let's assume the following table HTML
And our rowTemplate looks like this
So onload this is perfect, it takes an array of data from the database and pushes displays it just fine.
But what if you want to add just 1 row? Well using this setup you have to
So obviously that sucks. So you ask, why make the partial an each loop? Why not make the template and partial the one row?
If our row template was just
and the table was
Then we wouldn't have access to the parent data in the partial or the template because of the loop were inside of.
The only other alternative is to pass ../ into your partial, but then you lose the ability to each loop through your data. So that doesn't work either.
So TL;DR
The text was updated successfully, but these errors were encountered: