Changing tooltip content dynamically

3 posts, 1 answers
  1. Kelly
    Kelly avatar
    28 posts
    Member since:
    Oct 2012

    Posted 02 Aug 2013 Link to this post

    I'm sure this is an easy answer but I've looked high and low and cannot find the answer. How do I dynmically change the content of a tooltip? I'm using the following code:

    <div style="text-align:center;width:50%;margin:5px auto" class="inputbox numberSelected" id="ttAnchor"></div>
                            @(Html.Kendo().Tooltip()
                                .Callout(false)
                                .For("#ttAnchor")
                                .Position(TooltipPosition.Right)
                                .Width(200)
                                .Events(events => events.Show(
                                    @<text>
                                        function(e){
                                            e.content = "test";
                                        }
                                    </text>
                                    ))
                            )

    e.content does not seem to work. I'm sure I'm just missing a key word somewhere. I do want the content to change everytime the tooltip is shown.
  2. Answer
    Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 05 Aug 2013 Link to this post

    Hi Paul,

    You could use the ContentHandler method to attached a function in which you can handle the content creation:

    @(Html.Kendo().Tooltip()
            .For("#container")
            .ContentHandler("content")
     )
     
    <script type="text/javascript">
     
        function content(e) {
            return "some content";
        }
    </script>

    Regards,
    Rosen
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Kelly
    Kelly avatar
    28 posts
    Member since:
    Oct 2012

    Posted 05 Aug 2013 Link to this post

    I had been populating my content using the content handler but it only updated on the page load. I've since added a refresh call on the show and that seems to work fine.
Back to Top