{"id":20535507,"url":"https://github.com/satrong/knockout-pagination","last_synced_at":"2025-04-14T07:10:53.571Z","repository":{"id":90633851,"uuid":"39231159","full_name":"satrong/knockout-pagination","owner":"satrong","description":"Knockout.js分页插件","archived":false,"fork":false,"pushed_at":"2020-07-29T15:48:33.000Z","size":67,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T20:51:10.373Z","etag":null,"topics":["knockout","pagination"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satrong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-17T02:34:16.000Z","updated_at":"2019-08-31T01:48:05.000Z","dependencies_parsed_at":"2023-07-16T02:45:21.373Z","dependency_job_id":null,"html_url":"https://github.com/satrong/knockout-pagination","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrong%2Fknockout-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrong%2Fknockout-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrong%2Fknockout-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrong%2Fknockout-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satrong","download_url":"https://codeload.github.com/satrong/knockout-pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837287,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["knockout","pagination"],"created_at":"2024-11-16T00:31:55.627Z","updated_at":"2025-04-14T07:10:53.562Z","avatar_url":"https://github.com/satrong.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# knockout-page\nKnockout.js分页插件\n\n## 在线示例（Online demo）\n- http://satrong.github.io/knockout-pagination/demo/index.html\n- http://satrong.github.io/knockout-pagination/demo/ajax.html\n\n## 示例(Example)\nhtml代码：\n```html\n\u003cul data-bind=\"foreach:list\"\u003e\n\t\u003cli\u003e\u003cspan data-bind=\"text:id\"\u003e\u003c/span\u003e：\u003cspan data-bind=\"text:name\"\u003e\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv data-bind=\"page:currentPage\"\u003e\u003c/div\u003e\n```\njs代码：\n```js\nvar data = [\n\t{id:\"1\",name:\"a\"},\n\t{id:\"2\",name:\"b\"},\n\t{id:\"3\",name:\"c\"},\n\t{id:\"4\",name:\"d\"},\n\t...\n];\n\nvar Viewmodel = function(){\n\tthis.list = ko.observableArray();\n\tko.koPage.init(this,this.GetData,{\n\t\tpagesize:5\n\t});\n}\n\nViewmodel.prototype.GetData = function(pageindex){\n\tko.koPage.count(data.length);\n\tthis.list(data.slice((pageindex-1)*5,pageindex*5));\n}\nvar vm = new Viewmodel;\nko.applyBindings(vm);\n\n/// 当新增数据时 重置分页\ndata.unshift({id:\"0\",name:\"new\"});\nvm.pageReset();\n```\n\n## 使用方法(Usage)\n- `ko.koPage.init(self, callback, config)`: 初始化分页方法，参数(Arguments)介绍如下\n  * `self`: Viewmodel；\n  * `callback`: 处理数据，传入的参数为当前的页码(`currentPage`)；\n  * `config`: 自定义配置\n    * `next`: {`String`} 默认值：下一页\n    * `prev`: {`String`} 默认值：上一页\n    * `first`: {`String`} 默认值：首页\n    * `last`: {`String`} 默认值：末页\n    * `className`: {`String`} 给分页添加的样式， 默认值：pagination\n    * `linksCount`: {`Number`} 显示的页面按钮数据，若值为偶数则会自动加1，默认值：5\n    * `pagesize`: {`Number`} 每页显示的条数，必须根据实际情况设定，必须手动设置\n    * `showLinks`: {`Boolen`} 是否显示页码按钮，默认值：true\n- `ko.koPage.count(total)`: `total`为Number类型，设置总条数的快捷方法，在`callback`中用到，也可以直接使用`this.countItems(total)`\n- `page`: 自定义绑定方法，在视图中直接使用`data-bind=\"page:currentPage\"`即可\n- `this.pageReset(pageindex)`: {Number} 重置分页，默认值为`this.currentPage()`。当分页数据发生变化（新增或删除条数时）调用此方法可重置分页数据。\n\n## 注意事项\n- 一个ViewModel中只能使用一个分页\n- 在一个页面中有多个分页（多个ViewModel）时不能使用`ko.koPage.count`方法，需要使用`this.countItems`替代\n \n## 依赖(Dependencies)\n- Knockout\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrong%2Fknockout-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatrong%2Fknockout-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrong%2Fknockout-pagination/lists"}