2013-04-02 55 views
0

我將highslide與highcharts結合使用,並且我想修改關閉按鈕,更具體地說,當用戶單擊該「X」按鈕時我想調用附加功能。修改highslide彈出窗口的「X」關閉按鈕

當我檢查那個「X」按鈕,我在我的控制檯得到這個

<a href="#" title="Close (esc)" onclick="return hs.close(this)"><span>Close</span></a> 

我想要做這樣的事情

<a href="#" title="Close (esc)" onclick="return hs.close(this);myotherfunction();"><span>Close</span></a> 

但我無法找到其中的代碼那是位於。

我已經嘗試將這個添加到我的頭文件中的html文件本身,除了highslide.config.js手動覆蓋,但它沒有奏效。

hs.registerOverlay({ 
    html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>', 
    position: 'top right', 
    fade: 2 // fading the semi-transparent overlay looks bad in IE 
}); 

有人能幫我一個忙嗎?

////////////////////////////// updated 感謝Jeff B,我能夠完成所需的任務代碼看起來像這樣(儘管傑夫B中所示的例子也適用):

cursor: 'pointer', 
point: { 
    events: { 
     click: function(event) { 
      hs.htmlExpand(null, { 
       pageOrigin: { 
        x: this.pageX, 
        y: this.pageY 
       }, 
       headingText: this.ticker, 
       maincontentText: '<b>Detail:</b> ' + this.info, 
       width: 250 
      }); 

      alert('function goes here'); 

      hs.Expander.prototype.onBeforeClose = function(sender) { 
       alert('function goes here'); 
      }    
     }, 
    } 
}, 

回答

4

爲什麼修改按鈕? Highslide提供onBeforeClose原型:

hs.Expander.prototype.onBeforeClose = function (sender) { 
    myotherfunction(); 
} 

如果你想不同的時間還有一個onAfterClose原型。

onBeforeClose Documentation

演示:http://jsfiddle.net/xjKFp/

+0

謝謝你這麼多了點。不是將它作爲底部的獨立函數,而是將其包含在事件中,並使用click:function()括號。就像在我更新的帖子中。這樣做和做你的方式有區別嗎?任何優點和缺點? – D3Chiq

+0

@ D3Chiq:你這樣做的方式,你每打開一次圖表就應用原型函數*。你真的只想做一次。這樣做會浪費資源並可能導致問題。你想這樣做的唯一原因是,如果每次打開圖表時函數都需要更改,甚至可能有更好的方法。 –