{"id":16396253,"url":"https://github.com/ken107/databind-js","last_synced_at":"2025-03-21T02:32:26.005Z","repository":{"id":22609115,"uuid":"25951354","full_name":"ken107/databind-js","owner":"ken107","description":"A powerful and flexible MVC data binding library","archived":false,"fork":false,"pushed_at":"2024-11-07T06:30:53.000Z","size":111,"stargazers_count":18,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T05:53:44.309Z","etag":null,"topics":["data-binding","javascript","mvc","mvc-framework","web-component"],"latest_commit_sha":null,"homepage":"","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/ken107.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2014-10-30T02:31:45.000Z","updated_at":"2025-01-25T16:57:48.000Z","dependencies_parsed_at":"2024-01-31T00:45:53.990Z","dependency_job_id":"63914f49-f419-4412-9bdf-c6f569554a3a","html_url":"https://github.com/ken107/databind-js","commit_stats":{"total_commits":58,"total_committers":4,"mean_commits":14.5,"dds":"0.15517241379310343","last_synced_commit":"d12baacc1ea9429482d6c57f8a3128346c05c258"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fdatabind-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fdatabind-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fdatabind-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken107%2Fdatabind-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ken107","download_url":"https://codeload.github.com/ken107/databind-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244102760,"owners_count":20398386,"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":["data-binding","javascript","mvc","mvc-framework","web-component"],"created_at":"2024-10-11T05:06:51.991Z","updated_at":"2025-03-21T02:32:25.710Z","avatar_url":"https://github.com/ken107.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## What's This?\nData binding allows you to detect changes to your data and react by updating the DOM.\n\n## Installation\nFirst add databind.js to your page.\n```html\n\u003cscript src=\"http://cdn.rawgit.com/ken107/databind-js/master/databind.js\"\u003e\u003c/script\u003e\n```\nOr `bower install databinder`.\n\n## Detecting Changes To Your Data\nYour data is whatever `this` points to, which is by the default the `window` object.  Say your window object has the following property:\n```javascript\nwindow.blog = {\n\tname: \"My blog\",\n\tentries: [\n\t\t{ title: \"...\", text: \"...\", isPublished: true },\n\t\t{ title: \"...\", text: \"...\", isPublished: false }\n\t]\n}\n```\nTo bind to the text of the first blog entry, for example, use the _binding expression_ `#blog.entries[0].text`.\n\n## Updating the DOM\nSet the text content of an element\n```html\n\u003ch2\u003e{{#blog.entries[0].title}}\u003c/h2\u003e\n\u003cp\u003e{{#blog.entries[0].text}}\u003c/p\u003e\n```\n\nHide/show an element\n```html\n\u003cdiv bind-statement-1=\"thisElem.style.display = #blog.entries[0].isPublished ? 'block' : 'none'\"\u003e\n\t{{#blog.entries[0].text}}\n\u003c/div\u003e\n```\n\nChange an image\n```html\n\u003cimg bind-statement-1=\"thisElem.src = #blog.entries[0].isPublished ? 'checked.png' : 'unchecked.png'\" /\u003e\n```\n\nToggle a CSS class (using jQuery)\n```html\n\u003cli bind-statement-1=\"$(thisElem).toggleClass('published', #blog.entries[0].isPublished)\"\u003e\n\t{{#blog.entries[0].title}}\n\u003c/li\u003e\n```\n\nCall a function\n```html\n\u003cdiv bind-statement-1=\"doSomething(#blog.entries[0].text)\"\u003e\u003c/div\u003e\n```\n\nSay you want to repeat an element a number of times\n```html\n\u003cdiv bind-repeater-i=\"#blog.entries.length\"\u003e{{#blog.entries[#i].text}}\u003c/div\u003e\n```\n\nSet the value of an text box\n```html\n\u003cinput type=\"text\" bind-statement-1=\"thisElem.value = #blog.entries[0].title\" /\u003e\n```\n\nEt cetera.\n\nThe `bind-statement` specifies a JavaScript statement that should be executed every time your data changes.  It is one of just 6 _binding directives_ that together let you write responsive apps of any complexity.  They're no less capable than Angular or React.\n\nProceed to the [documentation](https://github.com/ken107/databind-js/wiki/Home) for the full list of binding directives.\n\n## Example\nhttp://jsfiddle.net/wcoczs50/4/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken107%2Fdatabind-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fken107%2Fdatabind-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken107%2Fdatabind-js/lists"}