{"id":18725549,"url":"https://github.com/jacklam718/autocompletejs","last_synced_at":"2025-11-11T19:30:12.311Z","repository":{"id":73765573,"uuid":"48369232","full_name":"jacklam718/autocompletejs","owner":"jacklam718","description":"A simple and extendable and no jQuery required JavaScript library for autocomplete","archived":false,"fork":false,"pushed_at":"2017-09-13T13:29:31.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T13:17:28.426Z","etag":null,"topics":[],"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/jacklam718.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":"2015-12-21T11:55:52.000Z","updated_at":"2017-09-13T13:13:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b9c7736-7395-4020-90b2-74c841b613c0","html_url":"https://github.com/jacklam718/autocompletejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklam718%2Fautocompletejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklam718%2Fautocompletejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklam718%2Fautocompletejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklam718%2Fautocompletejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacklam718","download_url":"https://codeload.github.com/jacklam718/autocompletejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239592980,"owners_count":19664855,"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-11-07T14:10:44.851Z","updated_at":"2025-11-11T19:30:11.993Z","avatar_url":"https://github.com/jacklam718.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutocompleteJs\nA simple and extendable and no jQuery required JavaScript library\n\n# Demo\n\u003ca href=\"http://jacklam718.github.io/autocompletejs\" target=\"_blank\"\u003e\n  LIVE DEMO\n\u003c/a\u003e\n\n\u003c!-- # Install\n### Bower\n```bash\nbower install --save autocompletejs\n```\n### NPM\n```bash\nnpm install --save autocompletejs\n```\n\n### CDN\n```html\n\u003cscript src=\"cdn/xxx/autocomplete.js\"\u003e\u003c/script\u003e\n``` --\u003e\n\n# Usage\n### import the library in your HTML template of script tag\n```html\n\u003cscript src=\"./build/js/autocomplete.js\"\u003e\u003c/script\u003e\n```\n### OR\n### if you using browserify you can use ```require```\n```javascript\nvar Autocomplete = require('autocompletejs');\n```\n\n### OR\n### ES6 import\n```javascript\nimport Autocomplete from 'autocompletejs';\n```\n\n```javascript\n// pass query selector to library\nvar elementId = '#autocomplete';\nvar autocomplete new Autocomplete(elementId);\n```\n\n\n```javascript\n// or pass DOM element to library\nvar inputElement = document.querySelector('#autocomplete');\nvar autocomplete new Autocomplete(inputElement);\n```\n\n# Example\n### in your HTML template\n```html\n\u003cinput type=\"text\" id=\"autocomplete\"\u003e\n```\n\n### in your JavaScript\n```javascript\nvar elem = document.querySelector('#autocomplete');\nvar autocomplete = new Autocomplete(elem);\n\nvar data = [\n  {name: 'The Wolverine'},\n  {name: 'The Smurfs 2'},\n  {name: 'The Mortal Instruments: City of Bones'},\n  {name: 'Drinking Buddies'},\n  {name: 'All the Boys Love Mandy Lane'}\n];\n\nautocomplete.setData(data);\n\nautocomplete\n  .on(autocomplete.ON_INPUT, function(data) {\n    // will call when on input\n  })\n  .on(autocomplete.ON_SELECT, function(suggestion) {\n    // will call when selected suggestion item\n  })\n  .on(autocomplete.ON_MOUSEOVER, function(index) {\n    // will call when mouse over suggestion item\n  })\n  .on(autocomplete.ON_ELEMENT_CREATED, function(suggestionsElement) {\n    // will call when the suggestions element container created\n  })\n  .on(autocomplete.ON_ELEMENT_REMOVED, function() {\n    // will call when the suggestions element container removed\n  });\n```\n\n##### if your data and the suggestions list is from server side, you can do this:\n```javascript\n// the following just a example, you can use any ways to fetch data from server side\n// in this case you don't need to call `setData` method\n\nvar elem = document.querySelector('#autocomplete');\nvar autocomplete = new Autocomplete(elem);\n\n$.ajax({\n  dataType: \"json\",\n  url: 'url/data',\n  data: {queryText: 'the keyword'},\n  success: function(suggestions) {\n    // the suggestions fetch from server side, then just directly pass the suggestions to `setSuggestionsAndCreateElement` method\n    autocomplete\n      .setSuggestionsAndCreateElement(suggestions);\n  }\n});\n```\n\n# TODO\n- [ ] Test case\n- [ ] Fetch data from server (because the suggestions list may be stored in server)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacklam718%2Fautocompletejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacklam718%2Fautocompletejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacklam718%2Fautocompletejs/lists"}