使用 tablesorter 我在 Firefox 中遇到以下问题。
如果我在向文本框添加文本后立即尝试排序,文本框模糊事件将不会总是触发。
请看下面的代码。谢谢您的帮助
// Jscript.js
$(document).ready(function () {
$.tablesorter.addParser({
id: 'coltwo',
is: function (s) {
return false;
},
format: function (s, table, cell) {
var temp = $('input', cell).val();
return temp.replace(",", "");
},
type: 'text'
});
$("#myTable").tablesorter({
headers: {
2: {
sorter: 'coltwo'
}
}
});
//http://mottie.github.com/tablesorter/docs/#Events
//update table and focus on table to try fire blur event
$("#myTable").bind("sortBegin", function () {
$(this).focus();
$('#myTable').trigger("update");
});
$(".txtInput").blur(function () {
var txt = $(this).val().replace("-",""); //remove this
$(this).val(txt + "z"); // add text to test if blur is working
});
});
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="js/jquery.tablesorter.js" type="text/javascript"></script>
<script src="js/JScript.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="myTable" class="tablesorter" border="1">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Due</th>
<th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>John</td>
<td><input type="text" value="aaaa" class="txtInput" /></td>
<td>$50.00</td>
<td>http://www.jsmith.com</td>
</tr>
<tr>
<td>Bach</td>
<td>Frank</td>
<td><input type="text" value="bbbb" class="txtInput" /></td>
<td>$50.00</td>
<td>http://www.frank.com</td>
</tr>
<tr>
<td>Doe</td>
<td>Jason</td>
<td><input type="text" value="cccc" class="txtInput" /></td>
<td>$100.00</td>
<td>http://www.jdoe.com</td>
</tr>
<tr>
<td>Conway</td>
<td>Tim</td>
<td><input type="text" value="dddd" class="txtInput" /></td>
<td>$50.00</td>
<td>http://www.timconway.com</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
</html>