Простенький вопрос - focus для компонента модального окна?
Здравств, значит тем похожых много, но я только начал разбиратся, не знаю как правильно прописать.
Так вот, при загрузке окна мне нужно выставить фокус в каком0то компоненте, пускай это будет первое текстовое поле. нашел код Ext.get('t1').focus(); не знаю где его вставить, и корректен ли он. нашел код listeners : { afterrender : function(field) { field.focus(true); } } но я успеваю только заметить курсор - потом он исчезает. Вот вся функция, - подскажите пожалуйста - как установить фокус? var me = this; Ext.apply(this, { height : 500, width : 500, modal : true, title : 'modal Window 500x500', plain : true, border : false, resizable : false, draggable : false, closable : true, items : [{ xtype : 'textfield', itemId : 'desc', margin : 5, width : 400, focusCls : 'x-form-focus', fieldLabel : 'Beschreibung' }, { xtype : 'textfield', itemId : 't1', margin : 5, width : 400, fieldLabel : 'Textfield1' }, { xtype : 'textfield', itemId : 't2', margin : 5, width : 400, fieldLabel : 'Textfield2' /*listeners : { afterrender : function(field) { field.focus(true); } }*/ }, { xtype : 'textfield', itemId : 't3', margin : 5, width : 400, fieldLabel : 'Textfield3' }, { xtype : 'textfield', itemId : 't4', margin : 5, width : 400, fieldLabel : 'Textfield4' }, { xtype : 'tabpanel', plain : true, layoutOnTabChange : true, margin : 5, width : 450, height : 200, items : [{ xtype : 'panel', title : 'Tab1', html : 'A simple Tag' }, { xtype : 'panel', title : 'Tab2', html : 'Another one' }] }], buttonAlign : 'center', buttons : [{ text : 'OK', handler : function() { me.close(); } }] }); Спасибо! |
у окна
listeners: { show: function(){ this.getComponent('t1').focus(true); } } |
Спасибо, вставил в этот блок
{ xtype : 'textfield', itemId : 't2', margin : 5, width : 400, fieldLabel : 't2', listeners : { show : function() { this.getComponent('t2').focus(true); } } } не работает |
Цитата:
Цитата:
|
Действительно не заметил, -
Вот, мне кажется правильно на этот раз? На такая же фишка, курсор появляется на мгновение и исчезает. :( Ext.define('My.view.core.dialog.par.ParExampleModalWindow', { extend : 'Ext.Window', alias : 'widget.core_dialog_par_example_modal_window', // constructor function constructor : function(config) { var me = this; Ext.apply(this, { height : 500, width : 500, modal : true, title : 'Modal Window 500x500', plain : true, border : false, resizable : false, draggable : false, closable : true, items : [{ xtype : 'textfield', itemId : 'desc', margin : 5, width : 400, focusCls : 'x-form-focus', fieldLabel : 'Beschreibung' }, { xtype : 'textfield', itemId : 't1', margin : 5, width : 400, fieldLabel : 'Textfield1' }, { xtype : 'textfield', itemId : 't2', margin : 5, width : 400, fieldLabel : 't2' }, { xtype : 'textfield', itemId : 't3', margin : 5, width : 400, fieldLabel : 'Textfield3' }, { xtype : 'textfield', itemId : 't4', margin : 5, width : 400, fieldLabel : 'Textfield4' }, { xtype : 'tabpanel', plain : true, layoutOnTabChange : true, margin : 5, width : 450, height : 200, items : [{ xtype : 'panel', title : 'Tab1', html : 'A simple Tag' }, { xtype : 'panel', title : 'Tab2', html : 'Another one' }] }], listeners : { show : function() { this.getComponent('t2').focus(true); } }, buttonAlign : 'center', buttons : [{ text : 'OK', handler : function() { me.close(); } }] }); My.view.core.dialog.par.ParExampleModalWindow.superclass.constructor .apply(this, arguments); } }); |
Никто не сталкивался? :(
|
Не факт, но попробуйте поиграться параметром delay, поставьте чуть больше, например 100,
this.getComponent('t2').focus(true, 100); проверьте, если будет все нормально, то можно поуменьшать |
Спасибо, попробую. :)
|
Часовой пояс GMT +3, время: 00:11. |