i need those both js file, one for adding row, and another for tablesort and pager. my problem neither script works, if they are both called.
this is my code so far :
<!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" xml:lang="en-us">
<head>
<title>jQuery plugin: Tablesorter 2.0</title>
<link rel="stylesheet" href="./css/style.css" type="text/css" />
<script type="text/javascript" src="./js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="./js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="./js/jquery.tablesorter.pager.js"></script>
<script >
$(document).ready(function()
{
$(document).on("click","#tdAdd",function(){
var newRow = $("<tr>");
var cols="";
cols+='<td><input type="button" id="tdAdd" value="+"/></td>';
cols+='<td><input type="button" class="tdDelete" value="-"/></td>';
cols+='<td><input type="text" value="enter data here"/></td>';
newRow.append(cols);
newRow.insertAfter($(this).closest("tr"));
});
});
</script>
</head>
<body>
<table id="insured_list" class="tablesorter">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Age</th>
<th>Premium Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mendes</td>
<td>Domnic</td>
<td>domnic@gmail.com</td>
<td>29</td>
<td>5500</td>
</tr>
<tr>
<td>
<input type="button" id="tdAdd" value="+"/>
</td>
<td>
<input type="button" class="tdDelete" value="-"/>
</td>
<td>
<input type="text" name="name" value="anything"/>
</td>
</tr>
</tbody>
</table>
<div id="pager" class="pager">
<form>
<img src="images/first.png" class="first"/>
<img src="images/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="images/next.png" class="next"/>
<img src="images/last.png" class="last"/>
<select class="pagesize">
<option value="">LIMIT</option>
<option value="2">2 per page</option>
<option value="5">5 per page</option>
<option value="10">10 per page</option>
</select>
</form>
</div>
<script defer="defer">
$(document).ready(function()
{
$("#insured_list")
.tablesorter({widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager")});
}
);
</script>
</body>
</html>
if i add this,for my defer script. neither script wont work. :
<script type="text/javascript" src="./js/jquery-1.3.1.min.js"></script>
EDIT :
<script type="text/javascript" src="./js/jquery-1.10.2.js"></script>
<script type="text/javascript">
var j1 = $.noConflict(true);
</script>
<script type="text/javascript" src="./js/jquery-1.3.1.min.js"></script>
<script type="text/javascript">
var j2 = $.noConflict(true);
</script>
<script type="text/javascript" src="./js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="./js/jquery.tablesorter.pager.js"></script>
<script >
$(document).ready(function()
{
j2("#insured_list")
.tablesorter({widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager")});
j1("#tdAdd").click(function(){
X();
});
});
function X(){
var newRow = $("<tr>");
var cols="";
cols+='<td><input type="button" id="tdAdd" value="+"/></td>';
cols+='<td><input type="button" class="tdDelete" value="-"/></td>';
cols+='<td><input type="text" value="enter data here"/></td>';
newRow.append(cols);
newRow.insertAfter($(this).closest("tr"));
}
This is the current script i tried and when i try to run it firebug says :
TypeError: $ is undefined $.extend({ jquery....rter.js (line 89) // jquery.tablesorter.js
TypeError: $ is undefined
$.extend(( jquery....ager.js (line 2) // jquery.tablesorter.pager.jsTypeError: $ is not a function
$(document).ready(function() tableso...2).html (line 19) // tablesorter(2).html