2014-12-02 40 views
1

你好,我有一個工具窗口。我有工具:'help',當點擊它時,我希望它從我的HTML文件輸出帶有文本的工具提示,但實際上它顯示alert('Help'),並且不會從文件輸出:輸出工具提示,如果點擊工具

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); 
      }); 
     }, 
    } 
] 

此圖爲什麼其實我是想:

enter image description here

+0

您正在使用的ExtJS的版本,使用下列? – 2014-12-02 15:00:34

+0

我使用分機4.2.1 – user3045654 2014-12-04 08:34:32

回答

0

您需要加載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); 
      } 
     }); 
    } 
} 
+0

謝謝你,我去試試吧 – user3045654 2014-12-04 08:35:11