Imagine that we have a widget with a list of nodes (e.g. divs). We would like to display a Dojo Tooltip on mouseover. The elements inside are generated dynamically, so we have to add Tooltips programmatically.
The strategy is to first define the Tooltip
single time during postCreate
and then pass it to handler-function which will dynamically add it to the nodes.
postCreate: function() {
var _this = this;
var fooTooltip = new Tooltip();
this.own(on(this, '.elements-container-item', function(e) {
lang.hitch(_this, 'onMouseOverHandler')(this, e, fooTooltip);
});
}
What is the proper way to dynamically assign Tooltip
to mouseover'ed element?
onMouseOverHandler: function(node, e, fooTooltip) {
fooTooltip.set('connectId', [node]); // doesn't work
fooTooltip.set('label', 'foo label'); // doesn't work as well
}