I\'am maintaining a GUI built using JQuery. In one part of the GUI, multiple tabs can be opened to edit data.
When a new tab is opened, it is created by cloning the firs
ID's are unique identifiers. The moment you introduce a duplicate id, you have an invalid document on your hands.
The best way to get around this is to refrain from using id's on anything that is going to be cloned. Instead, use a "unique" class name to identify the element. Then, when it is cloned, you can walk down the DOM to each copy of the class. jQuery has very good DOM traversal methods for this.
http://api.jquery.com/category/traversing/
Additionally: .children()
, .parent()
, .parents()
, and .siblings()
are particularly useful. I'd stay away from .find()
unless it cannot be helped. .find()
can be slow if you are searching through many, many nodes in the DOM. Since you're building an interface, this might be the case.