This is a migrated thread and some comments may be shown as answers.

attaching a tooltip to a listview item?

2 Answers 350 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
ZM
Top achievements
Rank 1
ZM asked on 29 Mar 2013, 10:11 PM
How would I attach a tooltip to each listview item?
I want to do something like the following:
<script type="text/x-kendo-tmpl" id="template">
    <div class="product">
        <img src="myimage.jpg" alt="${Name} image" id="${ModelID}" />
        <h2>${Name}</h2>
        <h3>Starting from: $${kendo.toString(parseFloat(Price), "n0")}</h3>
        <div class="edit-buttons">
            <a id="viewbtn" class="k-button k-button-icontext" href="\\#">View </a>
            <a id="tooltipbtn" class="k-button k-button-icontext" href="\\#">TOOLTIP</a>
            <p id="tooltipcontent" style="display:none">
                #for (var i=0; i<VariationsForProduct.length; i++){#
                    ${VariationsForProduct[i].Name} $${VariationsForProduct[i].StartingPrice}
                    <br />             
                # } #                  
            </p>
        </div>
    </div>
</script>
So when the user clicks on the "TOOLTIP" button, they see everything in the paragraph that is hidden below (id="tooltipcontent").

Is there an example of this somewhere? Attaching a tooltip to each item in a listview, with the tooltip content being populated from the listview item?

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 02 Apr 2013, 02:24 PM
Hi Zarko,

Please check this jsBin example which I prepared for you - it demonstrates a possible implementation of the described scenario. Note the tooltip initialization:
$("#listView").kendoTooltip({
    filter: ".product-view .showTooltip",
    showOn: "click",
    content: function (e) {
      var container = e.target.parent();
      return container.find(".tooltipcontent").html();
    }
});

In addition, using IDs in the template is not recommended as it will render more than once. Please consider working with classes as in the example above.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
ZM
Top achievements
Rank 1
answered on 03 Apr 2013, 09:58 PM
Perfect, thank you!
Tags
ToolTip
Asked by
ZM
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
ZM
Top achievements
Rank 1
Share this question
or