Search code examples
asp.net-mvctwitter-bootstrapbootstrap-popover

How to get Boostrap popover feature on an Html ActionLink in MVC?


I have a table with ActionLinks. I am trying to figure out how to wrap these so that I can display a bootstrap popover feature. Any help is appreciated!

Here is what I have before trying to make any changes to allow for Bootstrap-Popover feature:

<div class ="container">
<table class="table table-striped table-bordered">
    <tr>
        <th></th>
        <th></th>
        <th>Group Name</th>
        <th>Description</th>            
        <th>Last Change</th>
    </tr>

<% foreach (var item in Model) { %>

    <tr>
        <td>
        <% if (isAdmin) { %><%=Html.ActionLink("Edit", "Edit", new { id = item.GroupId }, new { @class = "fa fa-pencil", title = "Edit Group" })%>
        </td>
        <td><%= Html.ActionLink("Details", "Details", new { id=item.GroupId }, new { @class = "fa fa-info_circle", title = "Group Details"})%></td>
        <td><%= Html.Encode(item.GroupName) %></td>
        <td><%= Html.Encode(item.Description) %></td>            
        <td><%=Html.Action("ConvertToLocalTime", new {utcTime = item.LastChange})%></td>
    </tr>

<% } %>

</table>
</div>

Solution

  • I know the question is quite old, but I ended up here. So, that's what I got. Maybe I can help someone.

    The Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.

    <script type="text/javascript"> $(function () { $('[data-toggle="tooltip"]').tooltip() }) </script>

    and, then, in your code:

    @Html.ActionLink(" ", "Delete", null, new { id = item.id}, new { @class = "glyphicon glyphicon-remove", data_toggle ="tooltip", data_placement = "top", title = "Delete" })