4

I want to show an ExtJS ToolTip as the result of a button click. When the User clicks the "X" or clicks the button a 2nd time the ToolTip should disappear (note I did not say "hidden"). If the user clicks the button a third time the Tip should show up again.

My problem is that if you hover over the button, the ToolTip shows up. (See fiddle) I only want it as a result of a button click.

I have tried calling "remove()" on the component to remove it from the DOM in the "onbeforeclose()" and "beforehide()" events but the Tip still shows up on hover.

I also want to note that calling the "close()" method from the documentation does not actually trigger the "onbeforeclose()" event - which doesn't really make sense to me...

すべての Sencha の例では、ホバー時にヒントが表示されます。クリックイベントの後にのみヒントを表示することさえ可能ですか?

フィドルのコードは次のとおりです。

function onClick() {
    window.Ext.create('Ext.tip.ToolTip', {
        target: 'div123',
        html: 'I am a tip',
        autoShow: true,
        autoScroll: true,
        focusOnToFront: true,
        autoHide: true,
        closable: true
    });
}

window.Ext.create('Ext.Button', {
    id: 'btn123',
    renderTo: 'div123',
    text: 'click me',
    width: '100px',
    handler: onClick
});

また、ボタンをクリックするたびに新しいツールヒントを作成していることを認識していることにも言及したいと思います。私は認識しており、それは望ましい動作です。私の問題は、クリックするたびに新しいヒントを表示することです。ホバー時に古いヒントを表示するのではありません。

  1. ドキュメンテーション
  2. ExtJS の例
  3. 私のフィドル
4

1 に答える 1

3

を削除するtargetと、ホバーするものは何もなくなります。

メソッドを使用して、Ext.tooltip.Tooltip#show必要なときにツールチップを表示します。

作成されたツールチップへの参照を保持しdestroyて、必要なときに使用できるようにします。

更新された fiddleを参照してください。

最後に、ツールチップを自動的に非表示にしてもよろしいですか? それはあなたが全体的に達成しようとしていることと一致していないようです...

于 2013-08-21T20:29:00.980 に答える