{"action":"created","issue":{"url":"https://api.github.com/repos/beneverard/jqPagination/issues/45","labels_url":"https://api.github.com/repos/beneverard/jqPagination/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/beneverard/jqPagination/issues/45/comments","events_url":"https://api.github.com/repos/beneverard/jqPagination/issues/45/events","html_url":"https://github.com/beneverard/jqPagination/issues/45","id":56217414,"number":45,"title":"Changing list content length but not updating number of pages","user":{"login":"christraverse","id":9552268,"avatar_url":"https://avatars.githubusercontent.com/u/9552268?v=3","gravatar_id":"","url":"https://api.github.com/users/christraverse","html_url":"https://github.com/christraverse","followers_url":"https://api.github.com/users/christraverse/followers","following_url":"https://api.github.com/users/christraverse/following{/other_user}","gists_url":"https://api.github.com/users/christraverse/gists{/gist_id}","starred_url":"https://api.github.com/users/christraverse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christraverse/subscriptions","organizations_url":"https://api.github.com/users/christraverse/orgs","repos_url":"https://api.github.com/users/christraverse/repos","events_url":"https://api.github.com/users/christraverse/events{/privacy}","received_events_url":"https://api.github.com/users/christraverse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-02T10:13:19Z","updated_at":"2015-03-10T01:23:30Z","closed_at":null,"body":"I'm paginating some data from a json file and when I load the page it works fine.  I've written a search function for the data that leads to the number of items in the array being reduced (in this case, down to 5 pages of results), yet the 'first' and 'last' buttons when pressed revert to being of 11 pages, and in the case of page 11 where no records exist displays a blank page.\r\n\r\nI don't know if I'm explaining this fully, but if you go to http://jctrl-dev.azurewebsites.net/pickinfo/ and use the search term 'collect' and then use the first page or last page buttons you'll see what I mean."},"comment":{"url":"https://api.github.com/repos/beneverard/jqPagination/issues/comments/77979067","html_url":"https://github.com/beneverard/jqPagination/issues/45#issuecomment-77979067","issue_url":"https://api.github.com/repos/beneverard/jqPagination/issues/45","id":77979067,"user":{"login":"echoate","id":1248108,"avatar_url":"https://avatars.githubusercontent.com/u/1248108?v=3","gravatar_id":"","url":"https://api.github.com/users/echoate","html_url":"https://github.com/echoate","followers_url":"https://api.github.com/users/echoate/followers","following_url":"https://api.github.com/users/echoate/following{/other_user}","gists_url":"https://api.github.com/users/echoate/gists{/gist_id}","starred_url":"https://api.github.com/users/echoate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/echoate/subscriptions","organizations_url":"https://api.github.com/users/echoate/orgs","repos_url":"https://api.github.com/users/echoate/repos","events_url":"https://api.github.com/users/echoate/events{/privacy}","received_events_url":"https://api.github.com/users/echoate/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T01:23:30Z","updated_at":"2015-03-10T01:23:30Z","body":"I had the exact same issue.  After stepping through the code, I noticed my page handler was getting called twice when I clicked on the pagination links.  Turns out when you call  $('.pagination').jqPagination() multiple times (i.e. when you call it again after initial page load) it binds another instance of your page handler to the onclick events.  Now both instances of your page handler get called when you click on the pagination links, causing all kinds of unpredictable results as you noticed.  This jQuery behavior is documented here:\r\n\r\nhttp://api.jquery.com/on/\r\n\r\n\"As of jQuery 1.4, the same event handler can be bound to an element multiple times.\"\r\n\r\nAn apparent solution is described here:\r\n\r\nhttp://www.prozblog.com/2012/03/05/jquery-always-use-unbind-or-off-method-to-prevent-event-bubbling/\r\n\r\nIn other words, in jquery.jqpagination.js change:\r\n\r\n         base.$el.on('click.jqPagination', 'a', function (event) {\r\n\r\nto:\r\n\r\n         base.$el.off('click.jqPagination').on('click.jqPagination', 'a', function (event) {\r\n\r\nwhich results in subsequent initializations of jqPagination after initial page load to work as expected.\r\n\r\nGood luck!\r\n"}}