{"id":22076480,"url":"https://github.com/codecademy/backbone.declarative","last_synced_at":"2025-07-24T13:30:54.979Z","repository":{"id":3604845,"uuid":"4669505","full_name":"Codecademy/backbone.declarative","owner":"Codecademy","description":"A Backbone plugin that adds declarative model and collection event binding to Backbone Views.","archived":false,"fork":false,"pushed_at":"2022-04-05T11:50:10.000Z","size":15,"stargazers_count":53,"open_issues_count":0,"forks_count":4,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-06-27T00:54:57.901Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Phelthas/Demo_ButtonImageTitleEdgeInsets","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Codecademy.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-06-14T23:09:15.000Z","updated_at":"2024-04-12T14:24:26.000Z","dependencies_parsed_at":"2022-08-20T22:51:00.484Z","dependency_job_id":null,"html_url":"https://github.com/Codecademy/backbone.declarative","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Codecademy/backbone.declarative","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fbackbone.declarative","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fbackbone.declarative/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fbackbone.declarative/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fbackbone.declarative/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codecademy","download_url":"https://codeload.github.com/Codecademy/backbone.declarative/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fbackbone.declarative/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266850122,"owners_count":23995007,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-30T22:14:47.204Z","updated_at":"2025-07-24T13:30:54.718Z","avatar_url":"https://github.com/Codecademy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backbone.declarative\n\nA Backbone plugin that adds declarative model and collection event binding to Backbone Views.\n\n## Running the tests\n\n    git submodule update --init --recursive\n    open test/index.html\n\n## Usage\n\nWhen extending a view just specify your declarative `modelEvents` and `collectionEvents`.  \n\nExample:\n\n```javascript\nvar Section = Backbone.View.extend({\n  collectionEvents: {\n    'add': 'addNewExercise'\n  , 'remove': 'removeExercise'\n  }\n\n  modelEvents: {\n    'change:programming_language': 'onProgLangChange'\n  }\n  ...\n});\n```\n\nThe events will automatically be cleaned up when the view's `remove` or\n`stopListening` methods are called.\n\n## Usage in Todos example\n\nThe following is part of the TodoView class definition from the famous [Todos Example](http://backbonejs.org/docs/todos.html).  \n```javascript\nvar TodoView = Backbone.View.extend({\n  template: _.template($('#item-template').html()),\n\n  events: {\n    \"click .toggle\"   : \"toggleDone\",\n    \"dblclick .view\"  : \"edit\",\n    \"click a.destroy\" : \"clear\",\n    \"keypress .edit\"  : \"updateOnEnter\",\n    \"blur .edit\"      : \"close\"\n  },\n\n  initialize: function() {\n    this.listenTo(this.model, 'change', this.render);\n    this.listenTo(this.model, 'destroy', this.remove);\n  },\n  ...\n```\n\n\nUsing Backbone.declarative it becomes:\n```javascript\nvar TodoView = Backbone.View.extend({\n  template: _.template($('#item-template').html()),\n\n  events: {\n    \"click .toggle\"   : \"toggleDone\",\n    \"dblclick .view\"  : \"edit\",\n    \"click a.destroy\" : \"clear\",\n    \"keypress .edit\"  : \"updateOnEnter\",\n    \"blur .edit\"      : \"close\"\n  },\n\n  modelEvents: {\n    'change': 'render'\n  , 'destroy': 'remove'\n  }\n  ...\n```\n\n## API\n\n#### bindModelEvents\n\nTakes an event hash `modelEvents` with keys being the model event names to bind on and values being  \nfunctions or strings representing method names. (Also used internally for the declarative format).\n\n### unbindModelEvents\n\nRemoves all event handlers attached by the `bindModelEvents`.\n\n#### bindCollectionEvents\n\nSame as `bindModelEvents` but for collections.\n\n### unbindCollectionEvents\n\nSame as `bindModelEvents` but for collections.\n\n\n## License\nMIT License.  \nCopyright (c) 2022 Codecademy LLC\n\nContributors: [philfreo](https://github.com/philfreo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecademy%2Fbackbone.declarative","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecademy%2Fbackbone.declarative","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecademy%2Fbackbone.declarative/lists"}