浏览代码

Fix #19: add onDblClickRow event and add element to onClickRow event.

zhixin 11 年之前
父节点
当前提交
ddb06f9a03
共有 2 个文件被更改,包括 9 次插入2 次删除
  1. 3 0
      docs/examples.html
  2. 6 2
      src/bootstrap-table.js

+ 3 - 0
docs/examples.html

@@ -516,6 +516,9 @@
                                 onClickRow: function(row) {
                                     $result.text('Event: onClickRow, data: ' + JSON.stringify(row));
                                 },
+                                onDblClickRow: function(row) {
+                                    $result.text('Event: onDblClickRow, data: ' + JSON.stringify(row));
+                                },
                                 onSort: function(name, order) {
                                     $result.text('Event: onSort, data: ' + name + ', ' + order);
                                 },

+ 6 - 2
src/bootstrap-table.js

@@ -103,7 +103,8 @@
             return 'No matching records found';
         },
 
-        onClickRow: function(item) {return false;},
+        onClickRow: function(item, $element) {return false;},
+        onDblClickRow: function(item, $element) {return false;},
         onSort: function(name, order) {return false;},
         onCheck: function(row) {return false;},
         onUncheck: function(row) {return false;},
@@ -675,11 +676,14 @@
         this.$container.find('.fixed-table-body').scrollTop(0);
 
         this.$body.find('tr').off('click').on('click', function() {
-            that.options.onClickRow(that.data[$(this).data('index')]);
+            that.options.onClickRow(that.data[$(this).data('index')], $(this));
             if (that.options.clickToSelect) {
                 $(this).find(sprintf('[name="%s"]', that.options.selectItemName)).trigger('click');
             }
         });
+        this.$body.find('tr').off('dblclick').on('dblclick', function() {
+            that.options.onDblClickRow(that.data[$(this).data('index')], $(this));
+        });
 
         this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
         this.$selectItem.off('click').on('click', function(event) {