本文年代久远,很多内容已经过时,看官请注意哦。
网上找了一圈,没找到,只能自己动手了.
bootstrap treeview github的地址是:https://github.com/jonmiles/bootstrap-treeview
解开bootstrap-treeview的js代码,研究了一波,找到了我要修改的地方.
因为我使用的是min的版本,是编译后的,所以代码看起来不容易.
在f.settings = {...}添加
onMouseDown:d

var g = function(b, c) {
return this.$element = a(b),
this.elementId = b.id,
this.styleId = this.elementId + "-style",
this.init(c), {
在这后面添加:onMouseDown:a.proxy(this.onMouseDown,this)
g.prototype.subscribeEvents = function() {
this.unsubscribeEvents(),
this.$element.on("click", a.proxy(this.clickHandler, this)),
在这后面添加:
"function" == typeof this.options.onMouseDown && this.$element.on("mousedown", this.options.onMouseDown),
好了.
现在使用:
$('#treeview2').treeview({
levels: 1,
data: defaultData,
onNodeSelected: function(event, node) {
// alert(event);
},
onMouseDown:function(event,node){
if(event.which===3)
$("#test_id").html('<span>你按下了右键</span>');
}
});



评 说
正在取来评说……