Hi,
I'm trying to use the ToolTip component in Blazor and I would like to set the text using an attribute on the target element. This way I can have one SfTooltip compoenent and set the content on render based on which element has the tooltip
My code so far is like this:
<SfTooltip ID="nav-tooltip" Target="[tooltip]" OnRender="SetTooltipContent" Content="@TooltipContent">
<ul>
<li class="nav-item" tooltip="MyTooltip Text" id="ToolTipMenuItem" >
</li>
<li class="nav-item" tooltip="MyTooltip Other Text" id="ToolTipMenuItem2" >
</li>
</ul>
</SfTooltip>
@code
{
string TooltipContent = "Test content";
public async Task SetTooltipContent(TooltipEventArgs args)
{
string id = args.Target.ID;
string tooltip = await args.Target.GetAttribute<string>("tooltip");
TooltipContent = $"{id} - {tooltip}";
}
}
The string Id is set correctly - so I know that I am picking up the correct DOM element in the Target property. However, I am unable to discover how to get data from the GetAttribute method. This always seems to return null. I've tried changing the name of the attribute but I am unable to get any data.
As a side note -
string[] classes = await args.Target.GetClassList();
also returns null..
Am I calling these DOM methods from the wrong place in the life cycle of the component? What is the correct way to perform this operation?
Many thanks
Tim