简体   繁体   中英

Sencha Touch - Registering with ID issue

I am specifying an id property to 'Ext.Container' .

I want to reuse this container in different files. I want to get the childs of this container in multiple files.
But, since I specified an id for it, it gives me an error when I try to access it beyond first time ..

[WARN][Ext.Component#constructor] Registering a component with a id ( gBlock1 ) which has already been used. Please ensure the existing component has been destroyed ( Ext.Component#destroy() .

My code snippet ..

Ext.define('ABC.view.XYZ', {
    extend: 'Ext.Container',
    id: 'gBlock1',
    xtype: ...
    ......

I was using id property because I wanted to access all of Container's button in one go like this,

var buttons = Ext.ComponentQuery.query('#gBlock1 button');

and use it later as buttons[0] , buttons[1] etc ...

What should I do ? How to use itemsId as an alternative for it on Ext.Container

id is a special config in Sencha Touch and designed to be unique per component type, so do not try to use it multiple times.

In your case, there's a much more simple solution:

  • define some custom config, say:

    type: 'SpecialType';

  • query it later using:

    var buttons = Ext.ComponentQuery.query('button[type="SpecialType"]');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM