Extjs 如果单击工具,则输出工具提示
你好,我有一个工具窗口。我有一个工具:“帮助”,单击它时,我希望它输出一个工具提示,其中包含HTML文件中的文本,但实际上它显示了警报(“帮助”),并且它不会从文件中输出:Extjs 如果单击工具,则输出工具提示,extjs,tooltip,Extjs,Tooltip,你好,我有一个工具窗口。我有一个工具:“帮助”,单击它时,我希望它输出一个工具提示,其中包含HTML文件中的文本,但实际上它显示了警报(“帮助”),并且它不会从文件中输出: tools: [ { type: 'refresh', name: 'refresh', tooltip: 'reload' }, { type: 'help', handler: function (event, too
tools: [
{
type: 'refresh',
name: 'refresh',
tooltip: 'reload'
},
{
type: 'help',
handler: function (event, toolEl, panel) {
alert('Help');
var tooltips = [{
target: 'tip1',
html: 'A very simple tooltip'
}, {
target: 'ajax-tip',
width: 200,
autoLoad: {url: '/help/note/help.html'},
dismissDelay: 15000 // auto hide after 15 seconds
},
];
Ext.each(tooltips, function (config) {
Ext.create('Ext.tip.ToolTip', config);
});
},
}
]
这张图片显示了我真正想要的:
您需要在来自服务器的Ajay请求中加载html文件,然后在成功回调中创建工具提示
Ext.Ajax.request({
url: '/help/note/help.html',
success: function(response){
// in the success callback you get the html text in the response.responseText
// and then you can create a tooltip with the content of it
}
});
因此,您可以在回调中执行以下操作
var html = response.responseText;
var tooltip = {
target: 'ajax-tip',
width: 200,
html: html,
dismissDelay: 15000 // auto hide after 15 seconds
};
完整的代码应该是
{
type: 'help',
handler: function (event, toolEl, panel) {
Ext.Ajax.request({
url: '/help/note/help.html',
success: function (response) {
var html = response.responseText;
var tooltip = {
target: 'ajax-tip',
width: 200,
html: html,
dismissDelay: 15000 // auto hide after 15 seconds
};
Ext.create('Ext.tip.ToolTip', tooltip);
}
});
}
}
您正在使用哪个版本的ExtJs?