{"id":17963895,"url":"https://github.com/bramstein/knockout.selection","last_synced_at":"2025-03-25T05:32:23.449Z","repository":{"id":4592993,"uuid":"5735412","full_name":"bramstein/knockout.selection","owner":"bramstein","description":"A selection binding for Knockout.js","archived":false,"fork":false,"pushed_at":"2018-05-08T08:40:19.000Z","size":582,"stargazers_count":19,"open_issues_count":4,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-19T09:14:31.272Z","etag":null,"topics":[],"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/bramstein.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}},"created_at":"2012-09-09T06:09:09.000Z","updated_at":"2019-07-30T12:07:23.000Z","dependencies_parsed_at":"2022-08-31T04:22:53.769Z","dependency_job_id":null,"html_url":"https://github.com/bramstein/knockout.selection","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fknockout.selection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fknockout.selection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fknockout.selection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fknockout.selection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramstein","download_url":"https://codeload.github.com/bramstein/knockout.selection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407667,"owners_count":20610231,"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":[],"created_at":"2024-10-29T11:45:47.924Z","updated_at":"2025-03-25T05:32:23.116Z","avatar_url":"https://github.com/bramstein.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Knockout.js selection binding [![Build Status](https://travis-ci.org/bramstein/knockout.selection.png?branch=master)](https://travis-ci.org/bramstein/knockout.selection)\n\nThis binding implements a selection model that can be used with Knockout.js's `foreach` and `template` bindings, or other bindings through the `data` option. It handles multiple selections using `\u003cctrl\u003e`- and `\u003cshift\u003e`-click as well as keyboard navigation.\n\n## Usage\n\n    data-bind=\"foreach: \u003cobservableArray\u003e, selection: \u003cobservableArray\u003e\"\n\n    data-bind=\"foreach: \u003cobservableArray\u003e, selection: { selection: \u003cobservableArray\u003e, focused: \u003cobservable\u003e }\"\n\n    data-bind=\"selection: { data: \u003cobservableArray\u003e, selection: \u003cobservableArray\u003e, focused: \u003cobservable\u003e }\"\n\nIf you want to use the built-in keyboard navigation be sure to set `tabindex` so that your element can have focus and therefor receive keyboard events. See `examples/index.html` for an example on how to set `tabindex`.\n\n## Options\n\n### `data` \\\u003cobservableArray\\\u003e\n\nAn observable array that contains all items available to the selection model, as an alternative to the `foreach` and `template: { foreach: ... }` bindings.\n\n### `selection` \\\u003cobservableArray\\\u003e\n\nAn observable array that will reflect the currently selected items from the `foreach` or `template: { foreach: ... }` bindings, or from the `data` option.\n\n### `focused` \\\u003cobservable\\\u003e\n\nAn observable that contains the currently focused item. This might return `null` if there is no current focus.\n\n### `mode` \\\u003cobservable\\\u003e\n\nSet to `single` if the selection model should only allow a single selected item.\n\nIf set to `multi` users can use `\u003cctrl\u003e` and `\u003cshift\u003e` to select multiple items using either a mouse or keyboard.\n\nWhen set to `toggle` the selection model supports multiple selections, but selections are \"sticky\". Once selected they can only be deselect by selecting them again. This is useful on, for example, touch devices.\n\nSet to `off` to disable the selection.\n\nDefaults to `multi`.\n\nThe mode will be altered on the fly when the value of the observable changes.\n\n### `direction` \\\u003cstring\\\u003e\n\nSet to `horizontal` to allow navigating with left/right arrow keys, when `mode` is either `single` or `multi`.\n\nWhen set to `vertical`, the up/down arrow keys are available for navigating.\n\nDefaults to `vertical`.\n\n### `properties` \\\u003cobject\\\u003e\n\nThe selection binding will by default look for `selected` and `focused` observable properties on your `foreach` items and set them to true when the item is selected or focused. Using the `properties` option you can override these default property names to something else. For example:\n\n    data-bind=\"foreach: mylist, selection: { selection: mylistSelection, properties: { selected: 'active', focused: 'highlight' }\"\n\nThis will set the `active` and `highlight` observable properties on items in `mylist` when they are selected or focused.\n\n### `toggleClass` \\\u003cstring\\\u003e\n\nIn multi selection mode you can mark an element as a selection toggle. Clicking inside such an element will toggle the selection of the item the same way `\u003cctrl\u003e`-clicking does.\n\nThis is useful if you want checkboxes for the selected items.\n\nExample where the `toggleClass` is set to `checkbox`:\n\n```html\n\u003cul data-bind=\"foreach: items,\n               selection: { selection: selection, toggleClass: 'checkbox' }\"\u003e\n    \u003cli data-bind=\"css: { selected: selected, focused: focused }\"\u003e\n        \u003cspan class=\"checkbox\"\u003e\u003c/span\u003e\n        \u003cspan data-bind=\"text: text\"\u003e\u003c/span\u003e\n    \u003c/li\u003e\n\u003c/ul\u003e\n```\n\n### `lateSelect` \\\u003cboolean\\\u003e\n\nWhen `true`, delays selection of items to the `mouseup` event, which is useful when you need to intercept events, react to selections without interrupting either this library or for example drag-and-drop actions, etc. Mouseup events on a different element from the mousedown event will not select.\n\n## Running the tests\n\nThis test suite uses [Mocha](http://mochajs.org/) and\n[Expect.js](https://github.com/LearnBoost/expect.js).\n\nYou can run the tests in the browser by opening tests.html. It is also\nposible to run the tests from the console using [PhantomJS](http://phantomjs.org/), just run `npm test`.\n\n## Browser Support\n\nThis project supports the latest Internet Explorer, Firefox, Opera, Chrome, Safari, and Android browsers. Tests are run automatically on [all supported browsers](browsers.json) using [BrowserStack](http://www.browserstack.com/) and [browserstack-test](https://github.com/bramstein/browserstack-test).\n\n## Contributors\n\n* Sune Sloth Simonsen (@sunesimonsen)\n* Andreas Lind Petersen (@papandreou)\n* Maarten Winter (@mwoc)\n* Gustav Nikolaj Olsen (@gustavnikolaj)\n\n## License\n\nknockout.selection is licensed under the three clause BSD license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fknockout.selection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramstein%2Fknockout.selection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fknockout.selection/lists"}