I'm wondering is it possible to have a partial view display in a tooltip. I'm trying to design a page that has a group of students and when I hover over a student some details appear about them, a list of their subjects and some other details. I know I can put the items in the title, but I can't get all the info I need from there, and my details view has the info I need. Thanks in advance
Here's my current code
IEnumerable<StudentApp.Models.Student>
@foreach (var item in Model)
{ <div class="col-md-2 col-sm-4">
<img title="@item.Name, @item.StudentNo " class="img img-responsive" src="@item.StudentPic" />
</div>
}
@section scripts
{
<script type="text/javascript">
$(document).ready(function () {
$(document).tooltip();
});
</script>
}
Here's my details view
<div class="display-label">
@Html.DisplayNameFor(model => model.Name)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.Name)
</div>
<div class="display-label">
@Html.DisplayNameFor(model => model.StudentNo)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.StudentNo)
</div>
@foreach (var item in Model.Students)
{
<li>@item.Course</li>
}
You can use the
content
option to make the tooltip's contents whatever you need them to be. The MVC code could be placed anywhere in your page, so long as you can use jQuery to grab it (eg. in anoscript
tag or some such):Here's a fiddle demo: http://jsfiddle.net/guke50uw/
As you can use
$(this)
inside thecontent
function, you can make use of that with HTML data attributes to return different tooltips for the different items; depends on how your page is structured.