Reputation: 21430
I have seen the answer here but I don't understand it attaching Tooltip to item without fixed element 'id'
I am creating my Dojo Tooltips like this:
<script>
require(["dijit/Tooltip", "dojo/domReady!"], function(Tooltip){
new Tooltip({
connectId: ["div_1_1_2_1_1_1_2"],
label: "Please select a Country, Subsidiary before selecting a City."
});
new Tooltip({
connectId: ["div_1_1_2_1_2_1_2"],
label: "Please select a Country, Subsidiary before selecting a City."
});
});
</script>
My div
IDs are generated, so I would rather bind tooltips to another variable, such as my attribute:
data-viewid="Date_Time_Picker2"
Is this possible?
Upvotes: 0
Views: 984
Reputation: 7852
You can use dojo/query
to find your nodes by attributes. Per the dijit/Tooltip docs, connectId can be either ids or actual dom node references.
HTML:
<body class="claro">
<div><span data-viewid="attachATooltipToMe">Test one</span>
</div>
<div> <span data-viewid="attachATooltipToMe">Test two</span>
</div>
<div> <span data-viewid="attachATooltipToMe">Test three</span>
</div>
</body>
JS:
require(['dojo/query', 'dijit/Tooltip', 'dojo/domReady!'], function (query, Tooltip) {
var nodes = query('[data-viewid="attachATooltipToMe"');
new Tooltip({
connectId: nodes,
label: "Please select a Country, Subsidiary before selecting a City."
});
});
This will attach tooltips to each node that has the data-viewid attribute specified with a value of "attachATooltipToMe".
Upvotes: 3