removing an event
Umbrat24 opened this issue · 6 comments
If adding an event after initialization "onPage" multiple onPage events are fired.
Is there a possible way to destroy the bootpag object before adding an event or changing the total pages/max visible/current page options?
$('#pagination-here').bootpag({/* initial config */}).on("page", function(event, num){
// ... after content load -> change total to 10
$(this).bootpag({total: 10, maxVisible: 10});
});
For instance:
I have a search page that shows search results in a grid and provides a set of links for summary status' (open, closed, work in progress etc) I have the following 2 times
$('#btnSearch').click(function(){
$('#pagination-here').bootpag({total: 1}).on("page", function(event, num){
search(num) //populates grid and summary
$(this).bootpag({total: 10, maxVisible: 10});
})
})
$('body').on('click', '#sumary li .announceSearchStatus, function() {
//go to first page when filtering by status.
searchQueue(1)
search(num)
$(this).bootpag({total: 10, maxVisible: 10});
})
})
In this case the search function is called 2 times when clicking on any page.
I was able to work around this by unbinding the page event just before the call to search
$('#pagination-here').unbind('page') //prevents page event from being called 2 times
@Umbrat24 I have the same problem but using your work around, still I have the problem. Could you guide me exactly when should I unbind the event from page?
I went a different plugin route. The work around was to write this line of code before search(num)
For example
$('#pagination-here').unbind('page');
search(num);
Hope this helps some; its been a while since I encountered this
@Umbrat24 you are my hero...thanks :)