Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Define callback in settings. Callbacks execute on different events.
- `beforeRender` : Triggered before rendering going to call.
- `beforeRecordRender` : Triggered for each JSON object record at time of rendering.
- `afterFilter` : Triggered after filtering event.
- `beforeChangePage` : Triggered before change page of paginator.
- `afterChangePage` : Triggered after change page of paginator.

i.e.,

Expand All @@ -189,6 +191,12 @@ i.e.,
},
afterFilter: function(result){
// i.e Update result counter, update google map markers.
},
beforeChangePage: function(result) {
// i.e Delete a class to item.
},
afterChangePage: function(result) {
// i.e Insert a class to item.
}
};
```
Expand Down
20 changes: 17 additions & 3 deletions dist/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,17 @@
.replace(/\//g, '/');
};

var convertHtmlEntityToStr = function(string) {
return (''+string).replace(/&/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '\"')
.replace(/&#x27;/g, '\'')
.replace(/&#x2F;/g, '\/');
};

function templateBuilder(str, data) {
str = convertHtmlEntityToStr(str);
var c = templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
Expand Down Expand Up @@ -1420,7 +1430,7 @@

this.page = { currentPage: 1, perPage: opts.perPage.values };

this.paginator = new Paginator(this.lastResult().length, this.opts.pagination, function(currentPage, perPage){
this.paginator = new Paginator(this.execCallback, this.callbacks, this.lastResult().length, this.opts.pagination, function(currentPage, perPage){
self.page = { currentPage: currentPage, perPage: perPage }

if(self.has_search){
Expand Down Expand Up @@ -1463,9 +1473,11 @@



var Paginator = function(recordsCount, opts, onPagination) {
var Paginator = function(execCallback, callbacks, recordsCount, opts, onPagination) {
var paginationView;


this.execCallback = execCallback;
this.callbacks = callbacks;
this.recordsCount = recordsCount;;
this.opts = opts;
this.$container = $(this.opts.container);
Expand All @@ -1491,7 +1503,9 @@
var self = this;

$(this.opts.container).on('click', '[data-page]', function(e){
self.execCallback('beforeChangePage');
self.setCurrentPage($(this).data('page'));
self.execCallback('afterChangePage');
e.preventDefault();
});
};
Expand Down
Loading