jqueryEasyUI:tabs扩展:给tabs组件绑定双击事件 分类: JqueryEasyUI 2014-09-29 14:36 536人阅读 评论(0) 收藏

实现代码:

  1. $.extend($.fn.tabs.methods, {
  2.     /**
  3.      * 绑定双击事件
  4.      * @param {Object} jq
  5.      * @param {Object} caller 绑定的事件处理程序
  6.      */
  7.     bindDblclick: function(jq, caller){
  8.         return jq.each(function(){
  9.             var that = this;
  10.             $(this).children("div.tabs-header").find("ul.tabs").undelegate('li', 'dblclick.tabs').delegate('li', 'dblclick.tabs', function(e){
  11.                 if (caller && typeof(caller) == 'function') {
  12.                     var title = $(this).text();
  13.                     var index = $(that).tabs('getTabIndex', $(that).tabs('getTab', title));
  14.                     caller(index, title);
  15.                 }
  16.             });
  17.         });
  18.     },
  19.     /**
  20.      * 解除绑定双击事件
  21.      * @param {Object} jq
  22.      */
  23.     unbindDblclick: function(jq){
  24.         return jq.each(function(){
  25.             $(this).children("div.tabs-header").find("ul.tabs").undelegate('li', 'dblclick.tabs');
  26.         });
  27.     }
  28. });

使用方式:

  1. $(function(){
  2.     $('#tb').tabs('bindDblclick', function(index, title){
  3.         alert(title + ':' + index);
  4.     });
  5. });

摘自:http://www.easyui.info/archives/869.html

posted @ 2014-09-29 14:36  清山博客  阅读(582)  评论(0编辑  收藏  举报