Solved

jquery tablesorter rows with hover css

Posted on 2010-09-01
16
2,758 Views
Last Modified: 2012-05-10
Hello!

I am using jQuery 1.4.2 + jQuery UI 1.8.2 ( jQueryUI )

I am complementing that with jquery.tablesorter 2.0.3 + filter + paging ( jquery.tablesorter )


So, here is the deal.
In jquery.tablesorter CSS file I have the next code:
 
table.tablesorter tbody tr :hover
{
    background-color:#FBD34A;
}

Open in new window

This means that when my mouse goes over a <tr> inside the <tbody> it will display that color.

Although for some reason the entire row doesn't highlight. it only highlight the cell below the cursor.



¿anyone knows why this happens?
I am trying to avoid using jQuery onMouseOver and onMouseOut cause it will not be optimum.


in advance, many thanks!

PS: When I use this code instead the above one:
table.tablesorter tbody tr:hover
{
    background-color:#FBD34A;
}

Open in new window

it doesn't show anything on mouseover D: (note that I only deleted the space between the "tr" and the ":hover"
0
Comment
Question by:karelog
  • 9
  • 4
  • 3
16 Comments
 
LVL 8

Expert Comment

by:MelMc
ID: 33579346
Can you send the source or possibly use something like firebug to see exactly where the hover is geting applied?
0
 

Author Comment

by:karelog
ID: 33580107
here's the source, though I don't think you'll have the time to follow it. There are a several lines of code.


Parametros.aspx
0
 

Author Comment

by:karelog
ID: 33580123
Sorry the double post,

here is the main javascript and the css
jsCargos-Rubros.js
style.css
0
 

Author Comment

by:karelog
ID: 33580137
Sorry the triple post >.<

could you guide me on how to follow the css using firebug?
0
 

Author Comment

by:karelog
ID: 33580211
here is a picture of firebug and the css that recognize with hover
2010-09-01-14.02.00.png
0
 
LVL 8

Expert Comment

by:MelMc
ID: 33580262
try adding td after odd in the class
0
 

Author Comment

by:karelog
ID: 33580440
could you be more specific please?
0
 
LVL 8

Expert Comment

by:MelMc
ID: 33580496
change the name of the class table.tablesorter tbody tr :hover, table tablesorter tbody tr.odd :hover

Add this line to it
 table tablesorter tbody tr.odd td :hover
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:karelog
ID: 33580666

I tried several options using your advice, nevertheless I can't make it work.
I tried:
  • table tablesorter tbody tr.odd td :hover     nothing highlighted
  • table.tablesorter tbody tr.odd td :hover     nothing highlighted
  • table.tablesorter tbody tr :hover,
    table.tablesorter tbody tr.odd td :hover     highlighted only even CELLS
So it did not worked D:

0
 
LVL 8

Expert Comment

by:MelMc
ID: 33580886
Did you add the line i mentioned to the class or change the entire class name to only the line.

Ultimately the class name I wanted to try is this

table.tablesorter tbody tr :hover, table tablesorter tbody tr.odd :hover, table tablesorter tbody tr.odd td :hover
0
 

Author Comment

by:karelog
ID: 33580998
I actually replaced it :P

I tried again with your last code. Still the same problem.

Just to be clear, the problem is that the css is highlighting only the cell under the pointer of the mouse.
I need to make that the highlight extends to entire row, not only the cell.

I don't see how adding td (cell) to the class with help, cause I need the tr (row) to be highlighted

T_T
0
 
LVL 16

Expert Comment

by:Steve Krile
ID: 33597115
This should do the trick.  There are implied relationships in css script unless you explicitly use the ">" character.  I tried this in FF and IE and both worked.
<!DOCTYPE html>
<html>
	<head>
		<style>
			body{background:#fff;font-family:Arial, Helvetica, sans-serif; font-size:11px;margin: 10px auto;overflow:hidden;}
			table.tablesorter > tbody > tr:hover
			{
				background-color:#FBD34A;
			}

		</style>

		<script src="http://code.jquery.com/jquery-latest.min.js"></script>


	</head>
	<body>
		<table class="tablesorter">
			<tbody>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
			</tbody>
		</table>


	</body>

</html>

Open in new window

0
 

Author Comment

by:karelog
ID: 33597920
what the ">" character does exactly?

for some reason I think jQuery is interfiering in the styling.
each row has an "odd" or "even" class attached as you can see in the picture I attached in the earlier post, but in the css file is no "even" class defined T_T

I think I'm gonna die! T_T
0
 
LVL 16

Accepted Solution

by:
Steve Krile earned 500 total points
ID: 33598059
That character is a [parent] > [child] designator.

I think I've found your issue.  In the style, you have these two rules:

                  table.tablesorter tbody td {
                        color: #3D3D3D;
                        padding: 4px;
                        background-color: #FFF;
                        vertical-align: top;
                  }
                  table.tablesorter tbody tr.odd td {
                        background-color:#F0F0F6;
                  }

Notice that this applies background color to the TD tag.  So, the hover IS working, but you can't see it because the cell formatting is "on top" of the row.

So, the fix is attached.


<!DOCTYPE html>
<html>
	<head>
		<style>
			body{background:#fff;font-family:Arial, Helvetica, sans-serif; font-size:11px;margin: 10px auto;overflow:hidden;}
		/* tables */
		table.tablesorter {
			font-family:arial;
			background-color: #CDCDCD;
			margin:10px 0pt 15px;
			font-size: 8pt;
			width: 100%;
			text-align: left;
		}
		table.tablesorter thead tr th, table.tablesorter tfoot tr th {
			background-color: #e6EEEE;
			border: 1px solid #FFF;
			font-size: 8pt;
			padding: 4px;
		}
		table.tablesorter thead tr .header {
			background-image: url(bg.gif);
			background-repeat: no-repeat;
			background-position: center right;
			cursor: pointer;
		}
		table.tablesorter tbody td {
			color: #3D3D3D;
			padding: 4px;
			/*background-color: #FFF;*/
			vertical-align: top;
		}


		table.tablesorter tbody tr.even {
			background:#F0F0F6;
		}

		table.tablesorter tbody tr.odd {
			background:#FFFFFF;
		}

		table.tablesorter tbody tr:hover
		{
			background-color:#FBD34A;
		}


		table.tablesorter thead tr .headerSortUp {
			background-image: url(asc.gif);
		}
		table.tablesorter thead tr .headerSortDown {
			background-image: url(desc.gif);
		}
		table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
			background-color: #8dbdd8;
		}



		</style>

		<script src="http://code.jquery.com/jquery-latest.min.js"></script>


	</head>
	<body>
		<table class="tablesorter">
			<tbody>
				<tr class="odd">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="even">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="odd">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="even">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
			</tbody>
		</table>


	</body>

</html>

Open in new window

0
 

Author Closing Comment

by:karelog
ID: 33599144
=O

many many many thanks!!!!
you was so right!!
there IS a problem with that TD!!

I applied your css and all worked perfect!!!

Thanks!!! (I'll try to post the solution to the owner of the code in tablesorter.com, I'll reference you!)
0
 
LVL 16

Expert Comment

by:Steve Krile
ID: 33599190
It's hard to tell who is happier in these situations....the asker or the answerer.  Glad I could help.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now