{"id":17049411,"url":"https://github.com/samccone/marionette-behaviors","last_synced_at":"2025-06-24T00:31:22.571Z","repository":{"id":15291462,"uuid":"18021065","full_name":"samccone/marionette-behaviors","owner":"samccone","description":"a collection of useful marionette behaviors","archived":false,"fork":false,"pushed_at":"2014-07-27T23:59:46.000Z","size":258,"stargazers_count":63,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-12T15:57:42.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/samccone.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":"2014-03-22T22:16:19.000Z","updated_at":"2023-12-22T09:58:33.000Z","dependencies_parsed_at":"2022-07-31T03:48:54.316Z","dependency_job_id":null,"html_url":"https://github.com/samccone/marionette-behaviors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samccone/marionette-behaviors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fmarionette-behaviors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fmarionette-behaviors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fmarionette-behaviors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fmarionette-behaviors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samccone","download_url":"https://codeload.github.com/samccone/marionette-behaviors/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fmarionette-behaviors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261582553,"owners_count":23180610,"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-14T09:54:35.300Z","updated_at":"2025-06-24T00:31:22.554Z","avatar_url":"https://github.com/samccone.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Marionette Behaviors\n--------\n\nA collection of useful behaviors I have abstracted from my applications\n\n### Table of Contents\n\n  * [Closeable](#closeable)\n  * [ViewLinks](#viewlinks)\n  * [BottomScroller](#bottomscroller)\n  * [KeyEvents](#keyevents)\n  * [HtmlClass](#htmlclass)\n  * [AutoRegion](#autoregion)\n\n## Closeable\n\nCloses a view on click of an element with a class of `.close`. It also listens for a user to hit the `esc` key and then closes the view\n\n```coffeescript\nclass FooView extends Marionette.ItemView\n  behaviors:\n    Closeable: {}\n```\n\n## ViewLinks\n\nAllows you to define `v-href=\"route\"` within you tags for invoking `App.Router.navigate` passing your route.\n\n```coffeescript\nclass FooView extends Marionette.ItemView\n  behaviors:\n    ViewLinks: {}\n```\n\n** In your view template **\n```jade\nul\n  li\n    a(v-href=\"detail/{item.id}\")\n```\n\n## BottomScroller\n\nAllows you to scroll to the bottom of a given view `onRender` and on any passed events emitted on `App.vent`\n\n```coffeescript\nclass FooView extends Marionette.ItemView\n  behaviors:\n    BottomScroller: {\n      events: \"commentsUpdated\"\n    }\n```\n\n### Options\n\n#### Events\n  The `events` option can be `null`, a single string, or an array or strings.\n  All of the passed events will be set to listen on `App.vent`\n\n## KeyEvents\n\nThe `KeyEvents` behavior allows you to define global (single) key events that trigger view specific actions.\n\n```coffeescript\nclass FooView extends Marionette.ItemView\n  behaviors:\n    KeyEvents:\n      8:  -\u003e @deleteImage()\n      39: -\u003e App.vent.trigger('edit:advance')\n      37: -\u003e App.vent.trigger('edit:previous')\n      49: -\u003e @setActiveRating(0)\n      50: -\u003e @setActiveRating(1)\n      51: -\u003e @setActiveRating(2)\n      52: -\u003e @setActiveRating(3)\n      53: -\u003e @setActiveRating(4)\n      preventDefault: [8, 39, 37]\n\n  setActiveRating: -\u003e #...\n  deleteImage: -\u003e #...\n```\n\n### Options\nEach option key value actually represents the keyboard event key.\n\n#### preventDefault\nAny keyCode passed into this array will prevent the default action of the event.\n\n## HtmlClass\n\nThe `HtmlClass` behavior allows you to set a class on the `html` element on `onShow` and remove the class `onDestroy` of the view.\n\n```coffeescript\n  class MyView extends Marionette.ItemView\n    behaviors:\n      HtmlClass: {class: \"help-modal noover\"}\n```\n\n## AutoRegion\n\nDo you find yourself writing this code over and over again?\n\n```coffeescript\nclass MyView extends Marionette.LayoutView\n  onShow: -\u003e\n    @fooRegion.show(new BarView)\n    @zapRegion.show(new ZapView)\n```\n\nWell `AutoRegion` is the answer!\nWith a few declarative lines of code your regions will now auto populate.\n\n```coffeescript\nclass MyView extends Marionette.LayoutView\n  behaviors:\n    AutoRegion: {}\n\n  regions: -\u003e\n    fooRegion:\n      selector: \".bam\"\n      viewClass: MyViewClass\n      viewOptions: {} (or method def)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamccone%2Fmarionette-behaviors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamccone%2Fmarionette-behaviors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamccone%2Fmarionette-behaviors/lists"}