简体   繁体   中英

Sencha Touch - addAfter/insertAfter a component

is it actually possible to addAfter or insertAfter for components?

The documentation goes on about .add() to throw something to the end of a container but I'm looping through field's in my form and displaying their errors after each one. So I need to add a new component after these.

It seems that it's only possible on the actual element of these components? something like:

errorElement = Ext.create('Ext.Container', {
    //stuff
});
errorElement.element.insertAfter(field.element);

This is fine, it looks fine but if I do the following, the component doesn't seem to exist where the Dom stuff is:

Ext.Viewport.getActiveItem().query('panel'); // []
Ext.ComponentQuery.query('panel'); // Ext.apply.create.Class

Please don't tell me that I'm the only person who is asking about this sort of thing, how is this not highlighted anywhere in the documentation?

You can use Container.insert() method that Inserts a Component into this Container at a specified index .

However inserting an error Component (Component? not Element?) doesn't sound like a good idea. Default form fields already have an element for displaying errors inside them, and you can tweak its appearance through CSS.

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