I have been searching for a way to implement a hover-over popup with no luck. Because it is used on so many sites I thought it would be easy to find instructions, but I am wondering if I am missing something basic. I have looked at qTips2 and a few others, but these seem like way more than I need.
I have a Rails 3.1 app and want to display more details when a user hovers over a line in a table. Is this something built into Rails that I am missing, or do I need an add-on?
I sure would appreciate someone pointing me in the right direction.
I have been searching for a way to implement a hover-over popup with no luck. Because it is used on so many sites I thought it would be easy to find instructions, but I am wondering if I am missing something basic. I have looked at qTips2 and a few others, but these seem like way more than I need.
I have a Rails 3.1 app and want to display more details when a user hovers over a line in a table. Is this something built into Rails that I am missing, or do I need an add-on?
I sure would appreciate someone pointing me in the right direction.
Share Improve this question edited Oct 30, 2020 at 15:57 Temani Afif 273k28 gold badges363 silver badges482 bronze badges asked Dec 22, 2011 at 19:45 SteveO7SteveO7 2,4603 gold badges32 silver badges41 bronze badges 5- That would be a simple hovering div. – Sergio Tulentsev Commented Dec 22, 2011 at 19:50
- This isn't a Rails question, but rather a CSS or JavaScript question. – Wizard of Ogz Commented Dec 22, 2011 at 19:53
- Ha! javascript and css tags were added before I could get to it. – Wizard of Ogz Commented Dec 22, 2011 at 19:54
- We'll need a bit more explanation: 1) what do you mean with 'hover-over popup' (just the default browser tooltip, a styleable multiline div,...?) 2) what does your table html look like, and what items should trigger the mouseover? – ptriek Commented Dec 22, 2011 at 19:59
- 1 This should be marked as a duplicate of e.g. stackoverflow.com/questions/3559467/…, stackoverflow.com/questions/18359193/plain-javascript-tooltip or stackoverflow.com/questions/11683620/…. The currently shown duplicate has been deleted. – Ilmari Karonen Commented Jul 16, 2019 at 16:55
2 Answers
Reset to default 11Use some CSS and Javascript!
Here's an example you can play with: http://jsfiddle.net/cdpZg/
Copying it here, just in case.
HTML:
<div id='user'>I am a user. Move your mouse over me</div>
<div id='popup'>Extended info about a user</div>
<div>I a piece of useless information. No use hovering over me.</div>
CSS:
#popup {
height: 50px;
width: 200px;
text-align: center;
vertical-align:middle;
background-color: cornflowerblue;
color: white;
display: none;
padding-top: 8px;
position: absolute;
}
Javascript:
$(document).ready(function() {
$('#user').hover(function() {
$('#popup').show();
}, function() {
$('#popup').hide();
});
});
Just set the title on your link like this
<a title="Some text that will show up when I hover over this link">My link</a>