0

私のアプリケーションにはインジケーターのリストがあり、それぞれにヘルプ ボタンがあります。各ボタンをクリックすると、それぞれの定義を含む ToolTipDialog が表示されます。私がコードを書いた方法 (以下) では、ユーザーが最初のボタンをクリックした後にリスト内の別のヘルプ ボタンをクリックしても、コンテンツは更新されません。「コンテンツ」を動的に変更する方法を理解できませんでした。どんな助けでも大歓迎です:

HTML:

<div dojoType="dijit.layout.ContentPane" id="group1" title="Population projection" selected="true">
<table id="popIndTable">
<tr id="someID">
<td><input data-dojo-type="dijit.form.RadioButton" class="checkInd" id="checkCBR" name="checkInd" /></td>
<td id="indCBR">Crude Birth Rate</td>
<td id="infoCBR"><img id="imgCBR" src="Images/help_icon2.png"  width="16px" onClick="showToolTipDialog(this,this.id);" /></td>
</tr>
<tr>
<td><input data-dojo-type="dijit.form.RadioButton" class="checkInd" id="checkTest1" name="checkInd" /></td>
<td id="indTest1">Test 1</td>
<td id="infoTest1"><img id="imgTest1" src="Images/help_icon2.png"  width="16px" onClick="showToolTipDialog(this,this.id);" /></td>
</tr>
<tr>
<td><input data-dojo-type="dijit.form.RadioButton" class="checkInd" id="checkTest2" name="checkInd" /></td>
<td id="indTest2">Test 2</td>
<td id="infoTest2"><img id="imgTest2" src="Images/help_icon2.png"  width="16px" onClick="showToolTipDialog(this,this.id);" /></td>
</tr>
</table>
</div>

JavaScript:

function showToolTipDialog(node,infoId){
var infoText;
var infoElem = dojo.byId(infoId).parentNode.id;
if (infoElem == "infoCBR"){
infoText = "This is the text container for CBR";
}
else if (infoElem == "infoTest1"){
infoText = "This is the text container for Test1";
}
if (!tooltipDialog) {
tooltipDialog = new dijit.TooltipDialog({
content: infoText,
style: "width:200px;height:auto;",
autofocus: !dojo.isIE, // NOTE: turning focus ON in IE causes errors when reopening the dialog
refocus: !dojo.isIE
});
dijit.popup.open({ popup: tooltipDialog, around: node});
tooltipDialog.opened_ = true;
}
else {
if (tooltipDialog.opened_) {
dijit.popup.close(tooltipDialog);
tooltipDialog.opened_ = false;
}
else {
dijit.popup.open({popup: tooltipDialog, around: node});
tooltipDialog.opened_ = true;
}
}
}
4

3 に答える 3

1

Dojo ウィジェットの値をプログラムで変更する好ましい方法は、.set() メソッドを使用することだと思います。すなわち:

this.myTooltipDialog.set("content", newContent);

それよりも:

this.myTooltip.content = newContent;
于 2013-09-24T18:13:30.477 に答える
0

tooltipDialog の内容をリセットしたことがないようです。一度作成しますが、一度作成すると ( new dijit.TooltipDialog({...})) 静的なままになります。

Dojo API を知りません。しかし、コンテンツの値を直接設定することはできますか? おそらく最初の直後else

tooltipDialog.content = infoText;

これは推測にすぎませんが、Dojo の API が十分に単純であれば、うまくいくかもしれません。

if (!tooltipDialog) {そうでない場合は、チェックを外す必要があるかもしれません。

于 2012-07-09T18:05:16.690 に答える
-1

コンテンツが複雑すぎない場合は、呼び出しごとに新しい TooltipDialog を作成し、ぼかしたときにクリアすることをお勧めします。

var dlgDiv = dojo.create("div");
var dlg = new dijit.TooltipDialog({
    content: dlgDiv,
    onBlur: function () {
        popup.close(this);
        this.destroyRecursive();
    }
});

// you can create any content within dlgDiv at here dynamicly

dojo.popup.open({
    around: yourArondNode  ,
    orient: ["below", "before", "after", "above"],
    popup: dlg
});
dlg.focus();
于 2013-09-24T18:24:35.427 に答える