{"id":15619481,"url":"https://github.com/passy/flight-knockout","last_synced_at":"2025-04-28T13:26:13.175Z","repository":{"id":13009614,"uuid":"15688982","full_name":"passy/flight-knockout","owner":"passy","description":"Easy data-bindings in Flight with Knockout","archived":false,"fork":false,"pushed_at":"2017-05-17T09:27:12.000Z","size":13,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-13T18:08:34.557Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/passy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-06T23:09:46.000Z","updated_at":"2019-08-13T15:33:13.000Z","dependencies_parsed_at":"2022-09-09T23:21:01.332Z","dependency_job_id":null,"html_url":"https://github.com/passy/flight-knockout","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/passy%2Fflight-knockout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/passy%2Fflight-knockout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/passy%2Fflight-knockout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/passy%2Fflight-knockout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/passy","download_url":"https://codeload.github.com/passy/flight-knockout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242487509,"owners_count":20136651,"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-03T08:20:50.107Z","updated_at":"2025-03-08T01:31:46.072Z","avatar_url":"https://github.com/passy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flight-knockout\n\n[![Build Status](https://secure.travis-ci.org/passy/flight-knockout.png)](http://travis-ci.org/passy/flight-knockout)\n[![Code Climate](https://codeclimate.com/github/passy/flight-knockout.png)](https://codeclimate.com/github/passy/flight-knockout)\n[![Analytics](https://ga-beacon.appspot.com/UA-587894-18/flight-knockout/readme)](https://github.com/igrigorik/ga-beacon)\n\nA [Flight](https://github.com/flightjs/flight) mixin for data-binding with\n[Knockout](http://knockoutjs.com/).\n\n## Installation\n\nInstall through [Bower](https://github.com/bower/bower):\n\n```bash\nbower install --save flight-knockout\n```\n\nConfigure [RequireJS](http://requirejs.org/):\n\n```js\nrequirejs.config({\n    ...\n    paths: {\n        'flight': 'bower_components/flight',\n        'knockout': 'bower_components/component-knockout-passy/knockout',\n        'knockout-es5': 'bower_components/knockout-es5-passy/dist/knockout-es5'\n    }\n});\n```\n\n## Example\n\n*example.html*\n```html\n\u003cinput data-bind=\"value: name\"\u003e\n\u003cp\u003e\n    Name: \u003cspan data-bind=\"text: name\"\u003e\u003c/span\u003e\n\u003c/p\u003e\n\u003cbutton class=\"js-btn-cornify\"\u003eCornify\u003c/button\u003e\n```\n\n```js\ndefine([\n    'flight/lib/component',\n    'with_model',\n    'with_template'\n], function (defineComponent, withModel, withTemplate) {\n        function example() {\n            this.defaultAttrs({\n                buttonSelector: '.js-btn-cornify',\n            });\n\n            this.defaultModel({\n                name: 'No Name'\n            });\n\n            this.after('initialize', function () {\n                this.on('click', {\n                    buttonSelector: handleButton\n                });\n\n                // Assuming that `with_template` provides this for you.\n                this.renderTemplate('example.html');\n                this.bindViewModel();\n            });\n\n            this.handleButton = function () {\n                this.model.name = 'Sparkly ' + this.model.name + ' Sunshine';\n            };\n        };\n\n        // withModel has to come before your component so\n        // defaultModel works.\n        return defineComponent(withModel, example, withTemplate);\n    }\n);\n```\n\n## API\n\n### `withModel.defaultModel(attrs)`\n\nWorks analogous to `defaultAttr`. Takes an object and sets the default values of\n`this.model`.\n\n```js\nthis.defaultModel({\n    animal: 'Pony',\n    awesomeDude: 'Stephen'\n});\n```\n\nThese values are set during the `initalize` phase.\n\n### `withModel.bindViewModel([node, model, track])`\n\nBind a `model` to a specific DOM subtree (`node`). `node` defaults to the\nnode managed by the component, but can be overriden, e.g. for mixins. Setting\nthe `track` option to `false` *disables* automatic model tracking. The default\nbehavior is to watch the supplied `model` for changes via ES5 getters and\nsetters.\n\n### `withModel.unbindViewModel([node])`\n\nUnbinds all bindings from the given DOM `node`.\n\n### `withModel.subscribeTo(property, callback)`\n\nAdd a subscription to the current model. The callback is called\nwhenever the observed property changes.\n\n- `property`: String name of the property\n- `callback`: Function function called with the new value\n- returns a `Subscription` Object with a `dispose` method to unsubscribe.\n\n## Development\n\nDevelopment of this component requires [Bower](http://bower.io), and preferably\n[Karma](http://karma-runner.github.io) to be globally installed:\n\n```bash\nnpm install -g bower karma\n```\n\nThen install the Node.js and client-side dependencies by running the following\ncommands in the repo's root directory.\n\n```bash\nnpm install\nbower install\n```\n\nTo continuously run the tests in Chrome and Firefox during development, just run:\n\n```bash\nkarma start\n```\n\n## Contributing to this project\n\nAnyone and everyone is welcome to contribute. Please take a moment to\nreview the [guidelines for contributing](CONTRIBUTING.md).\n\n* [Bug reports](CONTRIBUTING.md#bugs)\n* [Feature requests](CONTRIBUTING.md#features)\n* [Pull requests](CONTRIBUTING.md#pull-requests)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpassy%2Fflight-knockout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpassy%2Fflight-knockout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpassy%2Fflight-knockout/lists"}