EasyUI Forum
May 14, 2024, 04:42:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: tree dnd (drag and drop) error Cannot read property 'NodeName' of undefined  (Read 6951 times)
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« on: August 17, 2015, 12:10:59 AM »

goor afternoon,

i have a problem using dnd feature on my tree.

here is my code:
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.
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« Reply #1 on: August 17, 2015, 08:35:49 PM »

there is still no solution for my problem??

i really need this feature.
thanks
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!