Skip to content

Commit

Permalink
Fix wenzhixin#3095: add event.preventDefault to href='#' link
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Dec 11, 2017
1 parent 2abf4bc commit 3fd238c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
24 changes: 8 additions & 16 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@
};

BootstrapTable.prototype.onPageListChange = function (event) {
event.preventDefault();
var $this = $(event.currentTarget);

$this.parent().addClass('active').siblings().removeClass('active');
Expand All @@ -1607,14 +1608,8 @@
return false;
};

// TODO: remove
BootstrapTable.prototype.onPageFirst = function (event) {
this.options.pageNumber = 1;
this.updatePagination(event);
return false;
};

BootstrapTable.prototype.onPagePre = function (event) {
event.preventDefault();
if ((this.options.pageNumber - 1) === 0) {
this.options.pageNumber = this.options.totalPages;
} else {
Expand All @@ -1625,6 +1620,7 @@
};

BootstrapTable.prototype.onPageNext = function (event) {
event.preventDefault();
if ((this.options.pageNumber + 1) > this.options.totalPages) {
this.options.pageNumber = 1;
} else {
Expand All @@ -1634,14 +1630,8 @@
return false;
};

// TODO: remove
BootstrapTable.prototype.onPageLast = function (event) {
this.options.pageNumber = this.totalPages;
this.updatePagination(event);
return false;
};

BootstrapTable.prototype.onPageNumber = function (event) {
event.preventDefault();
if (this.options.pageNumber === +$(event.currentTarget).text()) {
return;
}
Expand Down Expand Up @@ -1709,7 +1699,7 @@
html.push('<td>');

if (calculateObjectValue(null, this.options.detailFilter, [i, item])) {
html.push('<a class="detail-icon" href="javascript:">',
html.push('<a class="detail-icon" href="#">',
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen),
'</a>');
}
Expand Down Expand Up @@ -1920,7 +1910,9 @@
}
});

this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function () {
this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function (e) {
e.preventDefault();

var $this = $(this),
$tr = $this.parent().parent(),
index = $tr.data('index'),
Expand Down
16 changes: 1 addition & 15 deletions src/extensions/cookie/bootstrap-table-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
if (cookie.text !== '') {
$(element).val(cookie.text);
cachedFilters[cookie.field] = cookie.text;
}
}
});
};

Expand Down Expand Up @@ -236,10 +236,8 @@
_onSort = BootstrapTable.prototype.onSort,
_onPageNumber = BootstrapTable.prototype.onPageNumber,
_onPageListChange = BootstrapTable.prototype.onPageListChange,
_onPageFirst = BootstrapTable.prototype.onPageFirst,
_onPagePre = BootstrapTable.prototype.onPagePre,
_onPageNext = BootstrapTable.prototype.onPageNext,
_onPageLast = BootstrapTable.prototype.onPageLast,
_toggleColumn = BootstrapTable.prototype.toggleColumn,
_selectPage = BootstrapTable.prototype.selectPage,
_onSearch = BootstrapTable.prototype.onSearch;
Expand Down Expand Up @@ -348,12 +346,6 @@
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);
Expand All @@ -366,12 +358,6 @@
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 () {
_toggleColumn.apply(this, Array.prototype.slice.apply(arguments));

Expand Down

0 comments on commit 3fd238c

Please sign in to comment.