I follow the instruction for adding new table’s row from: Add table row in jQuery
A new row was successfully added but it didn’t get the other rows’ feature (highlight, draggable,…).
The table:
<table id="pubTab">
<thead>
<tr>
<td align="center">col1</td>
<td align="center">col2</td>
<td align="center">col3</td>
<td align="center">col4</td>
</tr>
</thead>
<tbody>
<tr id="1">
<td>+++<input type="text" size="40"/></td>
<td><input type="text" size="10"/></td>
<td><input type="text" size="50"/></td>
<td><input type="text" size="10" /></td>
</tr>
<tr id="2">
<td>+++<input type="text" size="40"/></td>
<td><input type="text" size="10"/></td>
<td><input type="text" size="50"/></td>
<td><input type="text" size="10"/></td>
</tr>
</tbody>
</table>
<input id="addPubTab" type="button" value="ADD" style="background-color:green; width: 170px"/>
The jQuery script:
<script type="text/javascript">
$(document).ready(function(){
$("#addPubTab").click(function(){
var id = "3";
var value = "<tr id=\""+id+"\">"+
"<td>+++<input type=\"text\" size=\"40\" name=\"collection_name\""+id+"/></td>"+
"<td><input type=\"text\" size=\"10\" name=\"service_name\""+id+"/></td>"+
"<td><input type=\"text\" size=\"50\" name=\"out_fname\""+id+"/></td>"+
"<td><input type=\"text\" size=\"10\" name=\"service_id\""+id+"/></td>"+
"</tr>";
$('#pubTab tbody').append(value);
});
});
</script>
The problem Problem: It added the new row but I cannot drag it (up/down) as I drag the other tow (there are no curser for dragging).
Inspecting elements resolve with:
<table id="pubTab">
<thead>_</thead>
<tbody>
<tr id=”1” style=”cursor: move; “ class>_</tr>
<tr id=”2” style=”cursor: move; “ class>_</tr>
<tr id=”3”>_</tr>
</tbody>
Please note that I am using the jQuery script (dragging/sorting):
$(function() { $("#pubTab:not(thead)").tableDnD(); });
Please assist.