{"id":21426332,"url":"https://github.com/phalbert/alpinejs-table","last_synced_at":"2026-01-03T00:53:20.435Z","repository":{"id":84438198,"uuid":"265386391","full_name":"phalbert/alpinejs-table","owner":"phalbert","description":"Fetching data with alpine.js; with pagination","archived":false,"fork":false,"pushed_at":"2024-05-30T10:30:05.000Z","size":8,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T07:29:54.691Z","etag":null,"topics":["alpinejs","html-css","html5","paginated-tables","pagination","table"],"latest_commit_sha":null,"homepage":"https://phalbert.github.io/alpinejs-table/","language":"HTML","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/phalbert.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-19T22:50:52.000Z","updated_at":"2024-12-31T20:38:19.000Z","dependencies_parsed_at":"2024-11-22T21:41:58.643Z","dependency_job_id":"06da1bb5-1626-46fc-b847-536b40bf0fa6","html_url":"https://github.com/phalbert/alpinejs-table","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/phalbert%2Falpinejs-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalbert%2Falpinejs-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalbert%2Falpinejs-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalbert%2Falpinejs-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phalbert","download_url":"https://codeload.github.com/phalbert/alpinejs-table/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933454,"owners_count":20370988,"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":["alpinejs","html-css","html5","paginated-tables","pagination","table"],"created_at":"2024-11-22T21:41:29.723Z","updated_at":"2026-01-03T00:53:20.394Z","avatar_url":"https://github.com/phalbert.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alpine.js Table Demo\n\nThis repository provides a simple demonstration of how [Alpine.js](https://alpinejs.dev/) can be used to create interactive, dynamic tables with features like:\n\n- **Search:** Filters table data based on user input.\n- **Threshold Selection:** Allows users to control filtering using a customizable threshold.\n- **Pagination:** Handles navigation through large datasets.\n- **Data Fetching:** Simulates retrieving data from an external API.\n\n## Key Alpine.js Concepts\n\n- **x-data:** Declares the component's reactive data state.\n- **x-model:** Creates two-way bindings for inputs (search field, select menu).\n- **x-for:** Iterates over data to dynamically generate table rows.\n- **@click:** Handles button clicks and calls functions.\n- **x-text:** Dynamically updates text content within table cells.\n- **x-if:** Conditionally displays elements (in this case, the table).\n- **Conditional Classes:** (`class=\"[ ... ]\"`) Enables the button's loading state styling.\n\n## Setup\n\n1. Clone this repository.\n2. Open the `index.html` file in a web browser.\n\n## Dependencies\n\n- **Alpine.js** (included via CDN)\n- **Bulma CSS** (included via CDN, for basic styling)\n\n## Explanation\n\nThe JavaScript code (within the `\u003cscript\u003e` tag) defines an Alpine.js component using the `getData()` function. Here's a breakdown of its properties and behavior:\n\n- **options:** Provides values for the threshold dropdown.\n- **searchValue:** Stores the text entered into the search field.\n- **page, limit, total:** Manages pagination state.\n- **events:** Stores the array of events fetched from the API.\n- **isLoading:** Tracks loading state for the button.\n- **previousPage, nextPage, lastPage:** Pagination variables.\n- **fetchData():**\n  - Fetches data from a mock API (`https://5d6516c05b26ae001489eb85.mockapi.io/api/v1/events`).\n  - Updates the events array and pagination state based on the response.\n\n## Notes\n\n- The API call simulates fetching data from a real backend. In a production app you'd replace this with your actual data source.\n- This example keeps the styling minimal (via [Bulma](https://bulma.io/)) to focus on the Alpine.js functionality.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalbert%2Falpinejs-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphalbert%2Falpinejs-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalbert%2Falpinejs-table/lists"}