{"id":15353757,"url":"https://github.com/westonganger/select-sync","last_synced_at":"2025-04-04T08:10:18.013Z","repository":{"id":58231186,"uuid":"82333536","full_name":"westonganger/select-sync","owner":"westonganger","description":"Javascript plugin for HTML `select` elements to synchronize by selected or disabled options","archived":false,"fork":false,"pushed_at":"2018-07-13T06:50:39.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T21:07:14.063Z","etag":null,"topics":["array","disabled","multi-select","select","selected","sync","synchronization"],"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/westonganger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-17T20:03:37.000Z","updated_at":"2018-07-13T06:50:40.000Z","dependencies_parsed_at":"2022-08-31T00:22:07.604Z","dependency_job_id":null,"html_url":"https://github.com/westonganger/select-sync","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonganger%2Fselect-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonganger%2Fselect-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonganger%2Fselect-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westonganger%2Fselect-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/westonganger","download_url":"https://codeload.github.com/westonganger/select-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142074,"owners_count":20890653,"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":["array","disabled","multi-select","select","selected","sync","synchronization"],"created_at":"2024-10-01T12:15:06.545Z","updated_at":"2025-04-04T08:10:17.985Z","avatar_url":"https://github.com/westonganger.png","language":"JavaScript","readme":"# select-sync\n\u003ca href=\"https://badge.fury.io/js/select-sync\" target=\"_blank\"\u003e\u003cimg height=\"21\" style='border:0px;height:21px;' border='0' src=\"https://badge.fury.io/js/select-sync.svg\" alt=\"NPM Version\"\u003e\u003c/a\u003e\n\u003ca href='https://www.npmjs.org/package/select-sync' target='_blank'\u003e\u003cimg height='21' style='border:0px;height:21px;' src='https://img.shields.io/npm/dt/select-sync.svg?label=NPM+Downloads' border='0' alt='NPM Downloads' /\u003e\u003c/a\u003e\n\u003ca href='https://ko-fi.com/A5071NK' target='_blank'\u003e\u003cimg height='22' style='border:0px;height:22px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=a' border='0' alt='Buy Me a Coffee' /\u003e\u003c/a\u003e \n\n`select-sync` is a plugin to synchronize selects by selected or disabled options. Works great for many selects which are for an array or multiple selects for one value.\n\nRequires a DOM library such as jQuery, Zepto, or any other $ library.\n\n# Install\n\n#### Yarn, NPM, or Bower\n```\nyarn add select-sync\n\nnpm install select-sync\n\nbower install select-sync\n```\n\n#### Rails Install\n```ruby\n# Gemfile\nsource 'https://rails-assets.org' do\n  gem 'rails-assets-select-sync'\nend\n\n\n# app/assets/javascripts/application.js\n/*\n *= require select-sync\n*/\n```\n\n# Usage\n```javascript\n$(\"select[name='myArray[]']\").selectSync('disableSelected', {\n  alwaysDisabledValues: [], // if you have some option values that should always stay disabled\n  beforeSync: function(selects){\n    // do something if you want to \n  },\n  afterSync: function(selects){\n    $(selects).trigger('chosen:updated');\n  }\n});\n\n$(\"select[name='myArray[]']\").selectSync('selected', {\n  beforeSync: function(selects){\n    // do something if you want to \n  },\n  afterSync: function(selects){\n    $(selects).trigger('chosen:updated');\n  }\n});\n\n// Remove select sync\n$('select[data-sync-disable-selected]').selectSync('disableSelected', 'destroy');\n$('select[data-sync-selected]').selectSync('selected', 'destroy');\n\n\n$('#add').click(function(){\n  // add new selects\n\n  //reinitialize sync to include new selects\n  $(\"select[name='myArray[]']\").selectSync('disableSelected', {\n    alwaysDisabledValues: [], // if you have some option values that should always stay disabled\n    beforeSync: function(selects){\n      // do something if you want to \n    },\n    afterSync: function(selects){\n      $(selects).trigger('chosen:updated');\n    }\n  });\n});\n```\n\n# Limitations\n\n* Currently can only have one sync per type per select.\n* Doesnt work for multi-selects. They try to solve the same issue as this plugin. I would try using a chosen multi-select before resorting to using this plugin.\n\n# Credits\nCreated by Weston Ganger - @westonganger\n","funding_links":["https://ko-fi.com/A5071NK'"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestonganger%2Fselect-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwestonganger%2Fselect-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestonganger%2Fselect-sync/lists"}