ソースを参照

Update responseHandler and add examples.

zhixin 11 年 前
コミット
44cc88c95a
2 ファイル変更5 行追加5 行削除
  1. 3 3
      docs/examples.html
  2. 2 2
      src/bootstrap-table.js

+ 3 - 3
docs/examples.html

@@ -347,12 +347,12 @@
                     </thead>
                 </table>
                 <script>
-                    // client
+                    // client side
                     function responseHandler(res) {
                         return res.repos;
                     }
 
-                    // server
+                    // server side
                     /*
                     function responseHandler(res) {
                         return {
@@ -360,7 +360,7 @@
                             total: res.repos.length
                         }
                     }
-                     */
+                    */
                 </script>
             </div>
             <div class="highlight"><pre><code class="language-html"></code></pre></div>

+ 2 - 2
src/bootstrap-table.js

@@ -757,14 +757,14 @@
             contentType: this.options.contentType,
             dataType: 'json',
             success: function(res) {
-                var data = res;
-
                 if (typeof that.options.responseHandler === 'function') {
                     res = that.options.responseHandler(res);
                 } else if (typeof that.options.responseHandler === 'string') {
                     res = eval(that.options.responseHandler + '(res)');
                 }
 
+                var data = res;
+
                 if (that.options.sidePagination === 'server') {
                     that.options.totalRows = res.total;
                     data = res.rows;