Title: tree dnd (drag and drop) error Cannot read property 'NodeName' of undefined
Post by: Opan Mustopah on August 17, 2015, 12:10:59 AM
goor afternoon, i have a problem using dnd feature on my tree. here is my code: // Place all the behaviors and hooks related to the matching controller here. // All this logic will automatically be available in application.js.
$(function(){ $('#tree_admin_pages').tree({ url: $('#admin_pages_data').data('tree-url'), method: "get", animate: true, lines: true, dnd: true, queryParams: {}, onStartDrag: function(node){ console.log(node); }, onStopDrag: function(node){ console.log(node);
}, onDrop: function(target,source,point){ console.log(target); console.log(source); console.log(point); }, onContextMenu: function(e, node){ e.preventDefault(); // expand current node tree jika ada child $(this).tree('expand',node.target); // select current node $(this).tree('select',node.target); // show menu action $('#cm_tree_admin_page').menu("show",{ top:e.pageY, left: e.pageX });
// dapatkan child current node var child = $(this).tree('getChildren', node.target); // jika node memiliki child maka menu delete disable if (child.length > 0){ $('#cm_tree_admin_page').menu('disableItem', $('#cm_tree_admin_page .delete_page')[0]); }else{ $('#cm_tree_admin_page').menu('enableItem', $('#cm_tree_admin_page .delete_page')[0]); }
}, onExpand: function(node){ // dapatkan child current node var child = $(this).tree('getChildren', node.target); // jika node memiliki child maka menu delete disable if (child.length > 0){ $('#cm_tree_admin_page').menu('disableItem', $('#cm_tree_admin_page .delete_page')[0]); } }, onLoadSuccess: function(node, data){ // expand all nodes saat success load $(this).tree("expandAll"); } });
// define ckeditor // CKEDITOR.replace('admin_page_page_content'); CKEDITOR.config.height = 400;
$('#cm_tree_admin_page').menu({ onClick: function(item){ var target = item.target, node = $('#tree_admin_pages').tree('getSelected'), subdomain = $('#admin_pages_data').data("subdomain"); // jika tidak ada node yang dipilih, maka return false if (node == []) return false; // check berdasarkan class if ($(target).hasClass("edit_page")){ // function dari nst_cms, nb: semua function dengan prefix nc* ada di nst_cms.js nc_dynamic_link({href: "/admin/pages/"+node.id+"/edit"}); // nc_dynamic_link({href: "/admin/pages/"+nc_parameterize(node.text)+"/edit"}); }else if ($(target).hasClass("delete_page")){ $.messager.confirm("Confirmation", "Are you sure?", function(r){ if (r){ nc_dynamic_link({href: "/admin/pages/"+node.id, "data-method": "delete", rel: "nofollow"}); } }); }else if ($(target).hasClass("show_page")){ if (node.forward_url == "" || node.forward_url == null){ nc_dynamic_link({href: nc_url_subdomain_build(subdomain)+node.path, target: "_blank"}); }else{ nc_dynamic_link({href: node.forward_url, target: "_blank"}); } } } });
$('#page_title').bind("keydown keyup", function(){ var obj_val = $(this).val(); $('#page_url').val(nc_parameterize(obj_val)); }); });
problem begin, when i start dragging and dropping tree node, and show lots of jquery error message. am i miss something on my code? i was using easyui version 1.4.3. many thanks for the answer.
Title: Re: tree dnd (drag and drop) error Cannot read property 'NodeName' of undefined
Post by: Opan Mustopah on August 17, 2015, 08:35:49 PM
there is still no solution for my problem??
i really need this feature. thanks
|