{"action":"created","issue":{"url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/309","repository_url":"https://api.github.com/repos/backbone-paginator/backbone.paginator","labels_url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/309/comments","events_url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/309/events","html_url":"https://github.com/backbone-paginator/backbone.paginator/issues/309","id":130459448,"number":309,"title":"Client mode reset, page calculation incorrect.","user":{"login":"bazineta","id":564060,"avatar_url":"https://avatars.githubusercontent.com/u/564060?v=3","gravatar_id":"","url":"https://api.github.com/users/bazineta","html_url":"https://github.com/bazineta","followers_url":"https://api.github.com/users/bazineta/followers","following_url":"https://api.github.com/users/bazineta/following{/other_user}","gists_url":"https://api.github.com/users/bazineta/gists{/gist_id}","starred_url":"https://api.github.com/users/bazineta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazineta/subscriptions","organizations_url":"https://api.github.com/users/bazineta/orgs","repos_url":"https://api.github.com/users/bazineta/repos","events_url":"https://api.github.com/users/bazineta/events{/privacy}","received_events_url":"https://api.github.com/users/bazineta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-01T19:33:11Z","updated_at":"2016-02-02T16:12:23Z","closed_at":null,"body":"In the reset event handler, line 510, there's the following:\r\n```\r\nif (pageCol.mode == \"client\") {\r\n  state.lastPage = state.currentPage = state.firstPage;\r\n}\r\npageCol.state = pageCol._checkState(state);\r\n```\r\nThus, on a reset, the state will be reset to the first page.  However, then, there's this:\r\n```\r\npageCol.reset(fullCol.models.slice(pageStart, pageEnd),\r\n  _extend({}, options, {parse: false}));\r\n```\r\nWhich is still using the originally-calculated pageStart and pageEnd values, which will not be that of the page state that was just reset to the first page.  Thus, the state has changed such that it's now on the first page, but the pageCol was just reset with the old pageStart, and pageEnd values, not those of the first page.\r\n\r\nThe following change to the line 510 block seems to be the right thing to do:\r\n```\r\n if (pageCol.mode == \"client\") {\r\n  // Fix paged view not resetting to first page when the full collection is reset in client mode.\r\n  firstPage = state.lastPage = state.currentPage = state.firstPage;\r\n  currentPage = firstPage === 0 ? state.currentPage : state.currentPage - 1;\r\n  pageStart = currentPage * pageSize;\r\n  pageEnd = pageStart + pageSize;\r\n}\r\n```\r\nBoth the state and view will then be in sync."},"comment":{"url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/comments/178660176","html_url":"https://github.com/backbone-paginator/backbone.paginator/issues/309#issuecomment-178660176","issue_url":"https://api.github.com/repos/backbone-paginator/backbone.paginator/issues/309","id":178660176,"user":{"login":"bazineta","id":564060,"avatar_url":"https://avatars.githubusercontent.com/u/564060?v=3","gravatar_id":"","url":"https://api.github.com/users/bazineta","html_url":"https://github.com/bazineta","followers_url":"https://api.github.com/users/bazineta/followers","following_url":"https://api.github.com/users/bazineta/following{/other_user}","gists_url":"https://api.github.com/users/bazineta/gists{/gist_id}","starred_url":"https://api.github.com/users/bazineta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazineta/subscriptions","organizations_url":"https://api.github.com/users/bazineta/orgs","repos_url":"https://api.github.com/users/bazineta/repos","events_url":"https://api.github.com/users/bazineta/events{/privacy}","received_events_url":"https://api.github.com/users/bazineta/received_events","type":"User","site_admin":false},"created_at":"2016-02-02T16:12:23Z","updated_at":"2016-02-02T16:12:23Z","body":"@wyuenho If you feel this to be a correct approach, I'd be happy to create a PR.  Just wanted to run it by you first."}}