I have a draggable table with preloaded “new items” – sorta like the Power Edit feature of the menu_editor module. Everything works perfect.
However, I want to have a button that adds a new row via jquery. I was able to do this via the following code. However, the new rows added by jquery are not draggable. What can i do to make it work? Is it even possible?
var preloaded_items_count = '.$preloaded_items_count.'; $("#edit-add-new-item").click(function(){ var append_tr = $("#guide-pages-table tr:last").clone(); var replace_pattern = new RegExp("new-" + preloaded_items_count, "g"); var new_item_id = "new-" + (preloaded_items_count + 1); //append_tr.find("a.tabledrag-handle").remove(); append_tr.html(append_tr.html().replace(replace_pattern,new_item_id)); preloaded_items_count = preloaded_items_count + 1; //Drupal.tableDrag.prototype.makeDraggable(append_tr); $("#guide-pages-table > tbody:last").append(append_tr); return false; });