{"action":"created","issue":{"url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/15","labels_url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/15/comments","events_url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/15/events","html_url":"https://github.com/infusion/jQuery-Paging/issues/15","id":48665297,"number":15,"title":"onSelect is fired on init and when the count is changed","user":{"login":"fenech","id":3943705,"avatar_url":"https://avatars.githubusercontent.com/u/3943705?v=3","gravatar_id":"","url":"https://api.github.com/users/fenech","html_url":"https://github.com/fenech","followers_url":"https://api.github.com/users/fenech/followers","following_url":"https://api.github.com/users/fenech/following{/other_user}","gists_url":"https://api.github.com/users/fenech/gists{/gist_id}","starred_url":"https://api.github.com/users/fenech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenech/subscriptions","organizations_url":"https://api.github.com/users/fenech/orgs","repos_url":"https://api.github.com/users/fenech/repos","events_url":"https://api.github.com/users/fenech/events{/privacy}","received_events_url":"https://api.github.com/users/fenech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-11-13T17:25:25Z","updated_at":"2015-06-26T17:12:31Z","closed_at":null,"body":"My `onSelect` handler uses AJAX to retrieve items. When I initialise the pagination, the contents of page 1 are already on the screen, so I don't want `onSelect` to fire on init and retrieve the same data again. At the moment I am dealing with this by using underscore.js `after` - `onSelect: _.after(2, myHandler)` but it would be better if the event simply didn't fire on init.\r\n\r\nOn a related note, the `onSelect` event is being fired whenever I change the number of items to be paginated. In my application I have a series of filters that can be applied to the the paged data. Of course, applying these filters changes the count. I have to do 2 separate requests, one to obtain the relevant items and the other to obtain the total number of items. Once I have the new number, I call `setNumber(newCount).setPage()` on my paging object. This fires the `onSelect` event, which requests the same data all over again.\r\n\r\nIs there a way to prevent `onSelect` from being fired in these two circumstances?"},"comment":{"url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/comments/115772187","html_url":"https://github.com/infusion/jQuery-Paging/issues/15#issuecomment-115772187","issue_url":"https://api.github.com/repos/infusion/jQuery-Paging/issues/15","id":115772187,"user":{"login":"jatmew","id":2395512,"avatar_url":"https://avatars.githubusercontent.com/u/2395512?v=3","gravatar_id":"","url":"https://api.github.com/users/jatmew","html_url":"https://github.com/jatmew","followers_url":"https://api.github.com/users/jatmew/followers","following_url":"https://api.github.com/users/jatmew/following{/other_user}","gists_url":"https://api.github.com/users/jatmew/gists{/gist_id}","starred_url":"https://api.github.com/users/jatmew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jatmew/subscriptions","organizations_url":"https://api.github.com/users/jatmew/orgs","repos_url":"https://api.github.com/users/jatmew/repos","events_url":"https://api.github.com/users/jatmew/events{/privacy}","received_events_url":"https://api.github.com/users/jatmew/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T17:12:31Z","updated_at":"2015-06-26T17:12:31Z","body":"Hi,\r\n\r\nI have run into this infinite loop issue when I simply want to do to redirect with the onSelect method. Reading above I see that this gets call on init() and probably why I am stuck in an infinite loop. For example my onSelect is the following function:\r\n\r\nfunction (page) { window.location.replace(url+page) }\r\n\r\nwhere url is path to a page. As you can see since the default page has this code on it, then it will infinitely loop. Any help will be appreciated.\r\n\r\nJames"}}