Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
'setupEvents' method moved to event delegation (issue josecebe#75 fixed)
  • Loading branch information
Eugene Simakin committed Sep 25, 2016
1 parent 9e2b60e commit e1adabf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
7 changes: 3 additions & 4 deletions examples/index.html
Expand Up @@ -19,13 +19,12 @@
var obj = $('#pagination').twbsPagination({
totalPages: 35,
visiblePages: 10,
href: true,
pageVariable: 'page',
onPageClick: function (event, page) {
console.info(page);
console.info(page + ' (from options)');
}
}).on('page', function (event, page) {
console.info(page + ' (from event listening)');
});
console.info(obj.data());
});
</script>
</body>
Expand Down
14 changes: 5 additions & 9 deletions jquery.twbsPagination.js
Expand Up @@ -210,18 +210,14 @@

setupEvents: function () {
var _this = this;
this.$listContainer.find('li').each(function () {
this.$listContainer.off('click').on('click', 'li', function (evt) {
var $this = $(this);
$this.off();
if ($this.hasClass(_this.options.disabledClass) || $this.hasClass(_this.options.activeClass)) {
$this.on('click', false);
return;
return false;
}
$this.click(function (evt) {
// Prevent click event if href is not set.
!_this.options.href && evt.preventDefault();
_this.show(parseInt($this.data('page')));
});
// Prevent click event if href is not set.
!_this.options.href && evt.preventDefault();
_this.show(parseInt($this.data('page')));
});
},

Expand Down

0 comments on commit e1adabf

Please sign in to comment.