jQuery EasyUI使用教程之樹的拖放控制

當在一個應用中使用樹插件時,拖拽和放置功能要求容許用戶改變節點位置。啓用拖拽和放置操做,全部您須要作的就是把樹插件的 'dnd' 屬性設置爲true。html

jQuery EasyUI最新試用版下載請猛戳>>jquery

添加節點到樹形菜單

建立樹

1ajax

2json

3服務器

4svn

$('#tt').tree({post

dnd: true,ui

url: 'tree_data.json'google

});url

當在一個樹節點上發生放置操做,'onDrop' 事件將被觸發,您應該作一些或更多的操做,例如保存節點狀態到遠程服務器端等。

1

2

3

4

5

6

7

8

9

10

11

12

13

onDrop: function(targetNode, source, point){

var targetId = $(target).tree('getNode', targetNode).id;

$.ajax({

url: '...',

type: 'post',

dataType: 'json',

data: {

id: source.id,

targetId: targetId,

point: point

}

});

}

下載EasyUI示例:easyui-tree-demo.zip

有興趣的朋友能夠點擊查看更多有關jQuery EasyUI的教程>>

相關文章
相關標籤/搜索