窗口弹出不断将其更改为Ext JS中的顶部

发布于 2025-01-18 17:26:47 字数 4368 浏览 6 评论 0原文

我的页面上有很少的文本框,日期选择器,手风琴和下降。在页面加载下,当我单击下拉列表时,弹出窗口并不是在特定位置。当我明确单击文本框时,弹出窗口就处于完美的位置。但是这种行为一直在改变。有时它以正确的位置显示,有时不显示。根据条件(基于选定的选项)可见名称文本框。还有其他一些字段还显示弹出窗口,但这些字段正确显示。

”在此处输入图像说明” 弹出代码

Ext.define('tooltip', {
extend: 'Ext.window.Window',
displayText: '',
header: '',
xtype: 'myWin',
width: 200,
height: 100,  
layout: 'fit',    
customId:'',
align:'center',    
cls: 'arrow-box',  
focusOnToFront: false,        
items: [{
    xtype : 'label',
    text: '',
    itemId:'lbldescription',
    height:20,
    width:183,
    style: 'padding-bottom: 8px; margin-top:-28px;',      
 },{
    xtype: 'component',
    itemId:'hrefLink',
    autoEl: {
        tag: 'a',           
        html: 'Learn about popup',
        href:'https://stackoverflow.com/questions/ask'
    },
    height:20,
    width:201,
    // style:{
    //    textAlign:'left',
    //    display:'block',
    //    margin-top:36
    // },
    
 }],
 
 buttons: [{
    text: 'Close',
    width:'100%',
    style:{
       textAlign:'left',
       display:'block'
    },
    handler: function(){
         this.destroy();
        }
 },{
    text: 'Do not show again',
    //width:'100%',
    style:{
       textAlign:'right',
       display:'block'
    },
    handler: function(btn){           
        localStorage.setItem(btn.up('myWin').customId, 1);          
        this.destroy();  
    }
 }],

 initComponent: function () {
          
    this.callParent();      
   
    this.id = this.customId;        
    this.setTitle(this.header);
        
    //Update text
    Ext.ComponentQuery.query('#lbldescription')[0].setText(this.displayText);       
}, 

})

主JS

                    fieldLabel: Name
                    labelClsExtra: 'x-form-item-label x-required',
                    name: 'Name',
                    itemId: 'Name',
                    xtype: 'textfield',
                    fieldCls: 'big',
                    width: 650,
                    enforceMaxLength: true,
                    maxLength: 1000,
                    isDisplayTooltip:false,
                    listeners: { 
                        focus: function(field, ev) {                           
                            var customId='nameTooltip';                            
                           
                            if ( field.isDisplayTooltip && parseInt(localStorage.getItem(customId)) != 1) {  
                              
                                field.suspendEvent('blur');
                                field.suspendEvent('focus');
                                
                                var displayMessage = 'This is popup';
                                field.popup =  Ext.create('tooltip',{
                                    displayText: displayMessage,
                                    customId:customId,
                                    header: Name
                                });

                                field.popup.showBy(field.el, 'l-r',[10-0]);                                    
                                field.focus();

                                field.resumeEvent('focus');                                  
                                field.resumeEvent('blur');  
                            }
                        },
                        blur: function(field,ev) {                             
                          
                             if(ev.relatedTarget === null){
                                field.popup.destroy();  
                                return;
                             }
                             if(ev.relatedTarget.id.indexOf('nameTooltip')<0 && ev.relatedTarget.parentNode.id.indexOf('nameTooltip') <0){
                                if( field.popup != undefined &&  field.popup != null)field.popup.destroy();                                  
                             }
                        },     
                    

I have few textboxes, date picker, accordion and drop down on my page. On page load when I click on tab from drop down, popup is not coming at a particular position. When I click on text box explicitly only then popup is coming at a perfect position. But this behavior is keeps changing. Some times it is displayed at a correct position and sometimes not. Name textbox will be visible based on condition(based on the selected option). And some other fields also displays popup but those are being displayed correctly.

enter image description here

enter image description here
PopupCode

Ext.define('tooltip', {
extend: 'Ext.window.Window',
displayText: '',
header: '',
xtype: 'myWin',
width: 200,
height: 100,  
layout: 'fit',    
customId:'',
align:'center',    
cls: 'arrow-box',  
focusOnToFront: false,        
items: [{
    xtype : 'label',
    text: '',
    itemId:'lbldescription',
    height:20,
    width:183,
    style: 'padding-bottom: 8px; margin-top:-28px;',      
 },{
    xtype: 'component',
    itemId:'hrefLink',
    autoEl: {
        tag: 'a',           
        html: 'Learn about popup',
        href:'https://stackoverflow.com/questions/ask'
    },
    height:20,
    width:201,
    // style:{
    //    textAlign:'left',
    //    display:'block',
    //    margin-top:36
    // },
    
 }],
 
 buttons: [{
    text: 'Close',
    width:'100%',
    style:{
       textAlign:'left',
       display:'block'
    },
    handler: function(){
         this.destroy();
        }
 },{
    text: 'Do not show again',
    //width:'100%',
    style:{
       textAlign:'right',
       display:'block'
    },
    handler: function(btn){           
        localStorage.setItem(btn.up('myWin').customId, 1);          
        this.destroy();  
    }
 }],

 initComponent: function () {
          
    this.callParent();      
   
    this.id = this.customId;        
    this.setTitle(this.header);
        
    //Update text
    Ext.ComponentQuery.query('#lbldescription')[0].setText(this.displayText);       
}, 

})

Main js

                    fieldLabel: Name
                    labelClsExtra: 'x-form-item-label x-required',
                    name: 'Name',
                    itemId: 'Name',
                    xtype: 'textfield',
                    fieldCls: 'big',
                    width: 650,
                    enforceMaxLength: true,
                    maxLength: 1000,
                    isDisplayTooltip:false,
                    listeners: { 
                        focus: function(field, ev) {                           
                            var customId='nameTooltip';                            
                           
                            if ( field.isDisplayTooltip && parseInt(localStorage.getItem(customId)) != 1) {  
                              
                                field.suspendEvent('blur');
                                field.suspendEvent('focus');
                                
                                var displayMessage = 'This is popup';
                                field.popup =  Ext.create('tooltip',{
                                    displayText: displayMessage,
                                    customId:customId,
                                    header: Name
                                });

                                field.popup.showBy(field.el, 'l-r',[10-0]);                                    
                                field.focus();

                                field.resumeEvent('focus');                                  
                                field.resumeEvent('blur');  
                            }
                        },
                        blur: function(field,ev) {                             
                          
                             if(ev.relatedTarget === null){
                                field.popup.destroy();  
                                return;
                             }
                             if(ev.relatedTarget.id.indexOf('nameTooltip')<0 && ev.relatedTarget.parentNode.id.indexOf('nameTooltip') <0){
                                if( field.popup != undefined &&  field.popup != null)field.popup.destroy();                                  
                             }
                        },     
                    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿嘿嘿 2025-01-25 17:26:47

我已经通过使用 showAt(x,y) 而不是 showBy(field.el,'lr',[10-0]) 解决了这个问题

  var elm =field.getEl();
  var x= elm.getX() + field.width+10;
  var height=field.getHeight();
  var getTopEnfOfInput=height+(height/2);
  var y= elm.getY()-getTopEnfOfInput;
  field.popup.showAt(x,y);    

I have resolved it by using showAt(x,y) instead of showBy(field.el,'l-r',[10-0])

  var elm =field.getEl();
  var x= elm.getX() + field.width+10;
  var height=field.getHeight();
  var getTopEnfOfInput=height+(height/2);
  var y= elm.getY()-getTopEnfOfInput;
  field.popup.showAt(x,y);    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文