Browse Source

editable: Fix shown/hidden events

shown: Should include editable argument
hidden: Should include reason argument, not editable
Johannes Schmid 10 years ago
parent
commit
99cb14a472

+ 1 - 1
src/extensions/editable/README.md

@@ -46,7 +46,7 @@ parameters: field, row, $el, editable
 
 Fired when an editable cell is hidden / closed.
 
-parameters: field, row, $el
+parameters: field, row, $el, reason
 
 ## The existing problems
 

+ 5 - 5
src/extensions/editable/bootstrap-table-editable.js

@@ -18,7 +18,7 @@
         onEditableShown: function (field, row, $el, editable) {
             return false;
         },
-        onEditableHidden: function (field, row, $el) {
+        onEditableHidden: function (field, row, $el, reason) {
             return false;
         }
     });
@@ -85,20 +85,20 @@
                     that.trigger('editable-save', column.field, row, oldValue, $(this));
                 });
             that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
-                .off('shown').on('shown', function (e) {
+                .off('shown').on('shown', function (e, editable) {
                     var data = that.getData(),
                         index = $(this).parents('tr[data-index]').data('index'),
                         row = data[index];
                     
-                    that.trigger('editable-shown', column.field, row, $(this));
+                    that.trigger('editable-shown', column.field, row, $(this), editable);
                 });
             that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
-                .off('hidden').on('hidden', function (e, editable) {
+                .off('hidden').on('hidden', function (e, reason) {
                     var data = that.getData(),
                         index = $(this).parents('tr[data-index]').data('index'),
                         row = data[index];
                     
-                    that.trigger('editable-hidden', column.field, row, $(this), editable);
+                    that.trigger('editable-hidden', column.field, row, $(this), reason);
                 });
         });
         this.trigger('editable-init');