原创

bootstrap treeview 绑定右键单击事件

本文年代久远,很多内容已经过时,看官请注意哦。

网上找了一圈,没找到,只能自己动手了.

bootstrap treeview github的地址是:https://github.com/jonmiles/bootstrap-treeview

解开bootstrap-treeview的js代码,研究了一波,找到了我要修改的地方.

因为我使用的是min的版本,是编译后的,所以代码看起来不容易.

在f.settings = {...}添加

onMouseDown:d

blob.png

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>');
      }
  });

blob.png

本文来自:bootstrap treeview 绑定右键单击事件-小码农,转载请保留本条链接,感谢!

温馨提示:
本文最后更新于 2022年03月01日,已超过 785 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我
正文到此结束
本文目录