I have around 500 - 1000 rows of entities called tests each of which has components. These components need to be shown when the user hovers over any test. Upon the mouseover
, I show the components information in a div and hide it upon mouseout
. I am able to do that just fine with hard coded top and left position. However, I need to be able to show that div to the right side of the cursor with a gap of 50 to 100 px.
How can I change my code to do that?
$(".test_row").mouseover(function (event) {
fillTestComponents(test, testId);
});
$(".test_row").mouseout(function (event) {
$("#testCompHolder").hide();
});
function fillTestComponents(test, testId) {
$.ajax({
type: 'GET',
url: "@Url.Action("GetTestComponents", "Templates", new { area = "Orders" })",
data: { testIdentifier: testId },
async: false,
success: function (data) {
var componentCount = data.length;
if (componentCount != 0) {
componentsHtml = "<p><u>" + test + "</u></p><ul>";
for (var i = 0; i < componentCount; i++) {
componentsHtml = componentsHtml + "<li>(" + data[i].TestIdentifier + ") " + data[i].Description + "</li>"
}
componentsHtml += "</ul>";
$('#testCompHolder').html(componentsHtml);
$("#testCompHolder").show();
}
else {
componentsHtml = "<p>No components exist for this test.</p>";
$("#testCompHolder").show();
}
},
error: function () {
alert('An error occurred while loading the results.');
}
});
}
HTML:
<div id="testCompHolder" style="display:none; padding: 4px; border: 2px black solid; background-color: #dddddd; position: fixed; top: 300px; left: 380px;">