How do you handle large repeating user interface elements with jQuery

Here's the situation:

You have a very complex user interface element that repeats in a list. Each has a menu on it, buttons, it hides and shows sub-elements, buttons for switching its state, etc. Etc. Elements are populated via JSON, so you need to build the elements and functionality of the fly.

What is the best way to accomplish this with jQuery? Where would you save the reusable template for the DOM structure? How would you add behavior? $ (). Live?. Livequery? by click? after each json get?

I think I just see how many people do different things. What is your work experience?

Any insight would be greatly appreciated.

+3
source share
1 answer

Without additional information, I would point you to these two places:

  • Question about various jquery template models
  • A proposal for a template to be part of jQuery. Part of the proposal is a discussion of how popular popular templates work.

Where would you save the reusable template for the DOM structure?

This is a simple question to answer, it seems that the trend is to put it into an element of scriptthe type text/html. Since most browsers do not know what to do with a script of this type, the element is ignored, but is still part of the DOM, so you can access it using the selector.

+4
source

Source: https://habr.com/ru/post/1746644/


All Articles