Home > Article > Web Front-end > Each component of extjs must set a unique ID, otherwise an error will occur_extjs
Each component of extjs must set a unique ID, otherwise it will cause various errors
EXTJS basically relies on ID to identify components. If you have a textfield with ID: "keyword" in panel1, and panel2 There is a textfield with the same ID in panel2. Then, when you close panel2, because extjs finds that the ID: "keyword" component in panel2 is still in use in panel1, it will not destroy it, so it becomes an isolated object. thus causing confusion.
No matter what, you must always remember that the object ID must be unique at all times. There are two ways to do this:
1. Do not specify an ID for the object, and then use the find method of the component to find the object through other attributes, such as find("name", "role"), and the result will be an array. Of course, your attributes are unique, so you can use find("name","role")[0] to reference the component.
2. You can also specify the child component in the form of parent component ID and child component ID. This method is better, and this is what extjs does internally. The ID of the child component becomes: this.id "_role ",Note that this here refers to the parent component. When instantiating, since the ID of the parent component must be unique, even if the same component is instantiated twice, the child components of the two instances have unique IDs. This can handle the ID duplication problem very well.