Solved

jquery tablesorter rows with hover css

Posted on 2010-09-01
16
2,804 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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
 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

809 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