Hello.
I asked such a question. Ext JS has a method Ext.getCmp('componentId') . It returns a component object, which is an object of a class (function). Given that it does not take an HTML element by its ID, it is actually an object. Well, here's the question:
How does this method work? Or how can I retrieve created objects by their ID? Any ideas and guesses.

PS:
A small clarification: the method retrieves by ID even those elements that are inside other objects (functions) of different nesting and of different types (even those that were created this way: var elem = new My.Element() ).

    2 answers 2

     document.getElmentById("id"); // возвращает объект document.elements["index/имя"]; // можно обращаться как к массиву 
    • Perfectly! But these are HTML elements! I asked about the other. How to extract objects of classes (functions)? - Anton Mukhin

    Having studied the source code for Ext JS , I still found the answer to my question:

    There is a simple saving of objects in the map in the global object. In each object, in the constructor, this object is added to the map. And the getCmp() method retrieves and returns the object created earlier from the map. Naturally, in each object there is an id property. For greater clarity, here is the code from the source:

      //конструктор глобального объекта //..... this.all = new Ext.util.HashMap(); //....... /** * Returns a component by { @link Ext.Component#id id}. * For additional details see { @link Ext.util.MixedCollection#get}. * @param {String} id The component { @link Ext.Component#id id} * @return Ext.Component The Component, <code>undefined</code> if not found, or <code>null</code> if a * Class was found. */ get : function(id) { return this.all.get(id); }, /** * Registers an item to be managed * @param {Mixed} item The item to register */ register: function(item) { this.all.add(item); }, 

    In principle, a convenient way to access any object created in the document.