I'm building a navigation system using lists (<ul>). All the categories and subcategories are being pulled from a MySQL database.
It looks like
Category 1
- Subcategory
- Element 1
Category 2
Category 3
When you click on a category it expands and shows the subcategories and so on. I am using CSS and Javascript to expand and contract the menu so it is possible that only 1 Category's data can be displayed at a time or all could be displayed at once.
My questions:
Should I a) make it so that when the user clicks on a category the script grabs the data for that category only? Or b) should I make it so that all Categories and their elements are retrieved?
I want this to be a flexible system so I can have unlimited elements if I wanted. I am concerned with the amount of time using (b) would need to retrieve and display the data.
I would also like to avoid refreshing the page because as a user I find it annoying (when I want to expand a list to see only one element).
If you have any ideas I would greatly appreciate it.
Thanks
D