浏览代码

Use method need to init table first.

zhixin 11 年之前
父节点
当前提交
411b414b52
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      src/bootstrap-table.js

+ 11 - 5
src/bootstrap-table.js

@@ -1135,22 +1135,28 @@
         this.each(function () {
         this.each(function () {
             var $this = $(this),
             var $this = $(this),
                 data = $this.data('bootstrap.table'),
                 data = $this.data('bootstrap.table'),
-                options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(), typeof option === 'object' && option);
-
-            if (!data) {
-                $this.data('bootstrap.table', (data = new BootstrapTable(this, options)));
-            }
+                options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(),
+                    typeof option === 'object' && option);
 
 
             if (typeof option === 'string') {
             if (typeof option === 'string') {
                 if ($.inArray(option, allowedMethods) < 0) {
                 if ($.inArray(option, allowedMethods) < 0) {
                     throw "Unknown method: " + option;
                     throw "Unknown method: " + option;
                 }
                 }
+
+                if (!data) {
+                    return;
+                }
+
                 value = data[option](_relatedTarget);
                 value = data[option](_relatedTarget);
 
 
                 if (option === 'destroy') {
                 if (option === 'destroy') {
                     $this.removeData('bootstrap.table');
                     $this.removeData('bootstrap.table');
                 }
                 }
             }
             }
+
+            if (!data) {
+                $this.data('bootstrap.table', (data = new BootstrapTable(this, options)));
+            }
         });
         });
 
 
         return typeof value === 'undefined' ? this : value;
         return typeof value === 'undefined' ? this : value;