jsTree插件简介(五)

HotKeys plugin

       JSTree的Hotkeys plugin实现键盘操作树结构,依赖于jquery.hotkeys.plugin。
hotkey 类似于键值操作,当点击键盘时,激活相应的事件操作。
默认的快捷键为:"up", "ctrl+up", "shift+up", "down", "ctrl+down", "shift+down", "left", "ctrl+left", "shift+left", "right", "ctrl+right", "shift+right", "space", "ctrl+space", "shift+space", "f2", "del"。

下面是使用快捷键的例子:
<h3>JSTree hotkeys</h3>

By default "up", "ctrl+up", "shift+up", "down", "ctrl+down", "shift+down", "left", "ctrl+left", "shift+left", <br/>
"right", "ctrl+right", "shift+right", "space", "ctrl+space", "shift+space", "f2", "del"<br/>

<div id="demo1" class="demo">
	<ul>
		<li id="phtml_1">
			<a href="#">Root node 1</a>
			<ul>
				<li id="phtml_2">
					<a href="#">Child node 1</a>
				</li>
				<li id="phtml_3">
					<a href="#">Child node 2</a>
				</li>
			</ul>
		</li>
		<li id="phtml_4">
			<a href="#">Root node 2</a>
		</li>
	</ul>
</div>


<h4>modify hotkeys please move to https://github.com/jeresig/jquery.hotkeys/blob/master/test-static-01.html</h4>
<script type="text/javascript" class="source">
$(function () {
	$("#demo1").jstree({ 
	  "core" : { "initially_open" : [ "phtml_1" ] },
	  "plugins" : ["themes","html_data","ui","crrm","hotkeys"]
	});
	//$("#demo1").jstree("disable_hotkeys");  
	
});

</script>

上例实现了利用键盘操作树结构的行为。如果不想使用快捷键,最简单的方法是将hotkeys插件从plugins中移除,或者使用代码中的注视部分
$("#demo1").jstree("disable_hotkeys"); 

如果要激活快捷键操作请使用$("#demo1").jstree("enable_hotkeys");函数。

另:也可以覆盖默认的快捷键,这是jquery插件的一部分,详见: jquery.hotkeys.plugin

上文源自: http://www.jstree.com/documentation/hotkeys 
代码请见: 代码 之hotkey-plugin.html

你可能感兴趣的:(function,Class,jquery插件,UP,plugins,themes)