浏览代码

Fix cookie extension onPage*** hook return values

The cookie extension hooks some of the bootstrap table methods to
implement saving the state. Unfortunately the onPage*** hooks don't
propagate the return values of the original hooked methods.

The original methods return false to ask jQuery to call
event.preventDefault() and event.stopPropagation(). Without this
clicking the pagination control caused my webpage to scroll to the top.
Istvan Pasztor 8 年之前
父节点
当前提交
2c490090fd
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      src/extensions/cookie/bootstrap-table-cookie.js

+ 6 - 0
src/extensions/cookie/bootstrap-table-cookie.js

@@ -359,31 +359,37 @@
     BootstrapTable.prototype.onPageNumber = function () {
         _onPageNumber.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
+        return false;
     };
 
     BootstrapTable.prototype.onPageListChange = function () {
         _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageList, this.options.pageSize);
+        return false;
     };
 
     BootstrapTable.prototype.onPageFirst = function () {
         _onPageFirst.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
+        return false;
     };
 
     BootstrapTable.prototype.onPagePre = function () {
         _onPagePre.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
+        return false;
     };
 
     BootstrapTable.prototype.onPageNext = function () {
         _onPageNext.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
+        return false;
     };
 
     BootstrapTable.prototype.onPageLast = function () {
         _onPageLast.apply(this, Array.prototype.slice.apply(arguments));
         setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
+        return false;
     };
 
     BootstrapTable.prototype.toggleColumn = function () {