[jQuery] TableSorter Problem
Hi everybody,
Sorry if not explain me well, the English is my second language :P
please try to get it.
This is the problem.
I wrote a widget(the first) for add to the tablesorter a rollover and
selected rows , works with the zebra widget or without it, the problem
begins here,
My widgets works fine until you sorted the table with the headers :( ,
when you do this mysteriously the events assigned to the rows begins
to staking and when you click the row the click event is repeated many
times as you clicked the headers, i tried to fix it but nothing, here
is the code:
Css------------------------------------------------------------------------------------------------
.RowOverMe{
}
.header {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color:#CCCCCC;
cursor:pointer;
background-color: #666666;
}
.row1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #D3DCFA;
}
.row2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #FFE6E6;
}
.rowover{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #FF99CC;
}
.rowselected {
background-color: #0099FF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: 100;
}
.overrowselected {
background-color: #59A7F4;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: 100;
}
EndCss-------------------------------------------------------------------------------------------
DefinedVars--------------------------------------------------------------------------------------
widgetZebra: {css: ["even","odd"]},
widgetRollOver:{css: ["over","selected","overselected"]},
EndDefinedVars-----------------------------------------------------------------------------------
Widget-------------------------------------------------------------------------------------------
$.tablesorter.addWidget({
id: "rollover",
format: function(table) {
var zebra =
($.inArray("zebra",table.config.widgets)!=-1)?true:false;
$("> tbody tr",table).mouseover(function(){
var TheIndex = $("> tbody
tr",table).index(this);
if(TheIndex%2==0){
if ($(this).attr("class") ==
table.config.widgetRollOver.css[1]) {
$
(this).removeClass().addClass(table.config.widgetRollOver.css[2]);
}else{
$
(this).removeClass().addClass(table.config.widgetRollOver.css[0]);
}
}else{
if ($(this).attr("class") ==
table.config.widgetRollOver.css[1]) {
$
(this).removeClass().addClass(table.config.widgetRollOver.css[2]);
}else{
$
(this).removeClass().addClass(table.config.widgetRollOver.css[0]);
}
}
}).mouseout(function(){
if(zebra){
var TheIndex = $("> tbody
tr",table).index(this);
if (TheIndex % 2 == 0) {
if($
(this).attr("class")==table.config.widgetRollOver.css[2]){
$
(this).removeClass().addClass(table.config.widgetRollOver.css[1]);
}else{
$
(this).removeClass().addClass(table.config.widgetZebra.css[0]);
}
}else{
if($
(this).attr("class")==table.config.widgetRollOver.css[2]){
$
(this).removeClass().addClass(table.config.widgetRollOver.css[1]);
}else{
$
(this).removeClass().addClass(table.config.widgetZebra.css[1]);
}
}
}else{
if($
(this).attr("class")==table.config.widgetRollOver.css[2]){
$
(this).removeClass().addClass(table.config.widgetRollOver.css[1]);
}else{
$(this).removeClass();
}
}
}).click(function(){
var TheIndex = $("> tbody
tr",table).index(this);
if (TheIndex % 2 == 0) {
if ($(this).attr("class") ==
table.config.widgetRollOver.css[2]) {
$
(this).find("input[type='checkbox']").attr("checked","");
$
(this).removeClass().addClass(table.config.widgetRollOver.css[0]);
}
else {
$
(this).find("input[type='checkbox']").attr("checked","checked");
$
(this).removeClass().addClass(table.config.widgetRollOver.css[2]);
}
}else{
if ($(this).attr("class") ==
table.config.widgetRollOver.css[2]) {
$
(this).find("input[type='checkbox']").attr("checked","");
$
(this).removeClass().addClass(table.config.widgetRollOver.css[0]);
}
else {
$
(this).find("input[type='checkbox']").attr("checked","checked");
$
(this).removeClass().addClass(table.config.widgetRollOver.css[2]);
}
}
});
}
});
EndWidget----------------------------------------------------------------------------------------
Why this is happening?
thank you for everything....