窗口弹出不断将其更改为Ext JS中的顶部
我的页面上有很少的文本框,日期选择器,手风琴和下降。在页面加载下,当我单击下拉列表时,弹出窗口并不是在特定位置。当我明确单击文本框时,弹出窗口就处于完美的位置。但是这种行为一直在改变。有时它以正确的位置显示,有时不显示。根据条件(基于选定的选项)可见名称文本框。还有其他一些字段还显示弹出窗口,但这些字段正确显示。
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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经通过使用 showAt(x,y) 而不是 showBy(field.el,'lr',[10-0]) 解决了这个问题
I have resolved it by using showAt(x,y) instead of showBy(field.el,'l-r',[10-0])