Created
June 18, 2012 18:34
-
-
Save ludo/2949901 to your computer and use it in GitHub Desktop.
Dynamically adding row to a jQuery treeTable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) Removed 'tabindex' (tabindex is something you probably use locally?). | |
// 2) Removed class="initialized", I don't think it is necessary. | |
var html_row = '<tr id="node-inserted-1">'; | |
// 3) Removed class ui-draggable. It should be added by jQuery draggable | |
// plugin. | |
html_row += '<td><span class="file">Simple element inserted after</span></td>'; | |
html_row += '<td>4 KB</td>'; | |
html_row += '<td>Plain text</td>'; | |
html_row += '</tr>'; | |
var newRow = jQuery(html_row); | |
//alert(newRow.parents("tr")); | |
var cquoi = jQuery(newRow[0]); | |
// 4) Added [0] so that plugin targets correct element. Not very pretty but it | |
// seems to work. | |
cquoi.appendBranchTo(jQuery("#node-1")[0]); | |
// 5) Are you trying to use drag-and-drop as well? The newly added row must be | |
// made draggable explicitly. I tried the following, which seems to work, | |
// but it is not very pretty. Perhaps livequery plugin could be used, or | |
// maybe draggable has some built-in 'live' mechanism. | |
$("#dnd-example .file, #dnd-example .folder").draggable({ | |
helper: "clone", | |
opacity: 0.75, | |
refreshPositions: true, | |
revert: "invalid", | |
revertDuration: 300, | |
scroll: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment