Summary

I have a list generated from laravel. The badge icon contains a count of the number of tracks. When hovering over the badge I want to see a popover with a list containing the titles of those tracks (at most 5).

List

Example

To put it into context this is similar to Facebook's 'like' link. When a user hovers over the link, a tooltip is displayed with a list of friends that have also liked it.

Facebook Like link

List set-up

My list is generated by the code below. It is in the {{ $tag->tracks->count() }} where the badge content comes from.

<ul class="list-group">

    @foreach($user->tags as $tag)

    <li class="list-group-item">

        {{ link_to("tags/$tag->mdbid", "$tag->text") }}

        <a href="#">

            <span class="badge pull-right">

                {{ $tag->tracks->count() }}

            </span>

        </a>

    </li>

    @endforeach

</ul>
有帮助吗?

解决方案

<button type="button" class="badge btn btn-default" data-trigger="hover" 
 data-toggle="tooltip" data-placement="top" 
 data-content="@foreach($tag->tracks as $track) {{ $track->title }} @endforeach">
   {{ $tag->tracks->count() }}
</button>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top