{"id":21513786,"url":"https://github.com/taketo1113/alt-ujs","last_synced_at":"2025-04-24T01:08:17.114Z","repository":{"id":264267005,"uuid":"846965629","full_name":"taketo1113/alt-ujs","owner":"taketo1113","description":"alternative rails-ujs","archived":false,"fork":false,"pushed_at":"2025-01-22T05:09:54.000Z","size":252,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T06:22:33.934Z","etag":null,"topics":["rails","rails-ujs","ujs"],"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/taketo1113.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-08-24T13:13:51.000Z","updated_at":"2025-01-22T05:09:57.000Z","dependencies_parsed_at":"2024-11-23T01:32:30.005Z","dependency_job_id":"4aac76bd-bfe8-42a7-b592-48d55249d450","html_url":"https://github.com/taketo1113/alt-ujs","commit_stats":null,"previous_names":["taketo1113/alt-ujs"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taketo1113%2Falt-ujs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taketo1113%2Falt-ujs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taketo1113%2Falt-ujs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taketo1113%2Falt-ujs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taketo1113","download_url":"https://codeload.github.com/taketo1113/alt-ujs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235374614,"owners_count":18979734,"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":["rails","rails-ujs","ujs"],"created_at":"2024-11-23T23:16:59.594Z","updated_at":"2025-01-24T01:52:12.230Z","avatar_url":"https://github.com/taketo1113.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alt-ujs\n\n**alt-ujs** is an alternative to *rails-ujs*.\n\n## rails-ujs\n\n*rails-ujs* has been deprecated since Rails 7.0 and was no longer released starting from Rails 7.2.\n\n*rails-ujs* is the unobtrusive scripting adapter for Ruby on Rails.\n\u003e This unobtrusive scripting support file is developed for the Ruby on Rails framework, but is not strictly tied to any specific backend.\n\nhttps://github.com/rails/rails/tree/7-1-stable/actionview/app/javascript\n\n## Features\n\n**alt-ujs** provides the following features compatible with *rails-ujs*:\n\n- force confirmation dialogs for various actions;\n- make non-GET requests from hyperlinks;\n- ~~make forms or hyperlinks submit data asynchronously with Ajax;~~\n  - Not Supported\n- have submit buttons become automatically disabled on form submit to prevent double-clicking.\n\n## Installation\n\n```sh\nnpm install alt-ujs\n```\n\n## Usage\n\nalt-ujs works by adding data attributes to your HTML.\nThe available data attributes are:\n\n- `data-confirm` : Displays confirmation dialogs for links and forms.\n- `data-method` : Enables links to perform POST, PUT, or DELETE requests.\n\nNext, add the following code to your app.\nThis code activates the functionality of elements with the specified data attributes.\n\n```js\n// your-app.js\nimport AltUjs from \"alt-ujs\";\nAltUjs.start();\n```\n\n### `data-confirm`\n\nThe `data-confirm` attribute displays confirmation dialogs for links and forms.\n\n```html\n\u003ca href=\"/path\" data-confirm=\"message\"\u003eLink\u003c/a\u003e\n\n\u003cbutton type=\"button\" data-confirm=\"message\"\u003eButton\u003c/button\u003e\n\u003cinput type=\"submit\" value=\"Submit\" data-confirm=\"message\"\u003e\n```\n\nThe text specified in the `data-confirm` attribute is shown in a JavaScript `confirm()` dialog.\nIf \"Cancel\" is selected, no further actions will be performed.\n\n### `data-method`\n\nThe `data-method` attribute allows you to execute a request with a specified HTTP method instead of the default GET method when clicking a link.\n\n```html\n\u003ca href=\"/path\" data-method=\"post\"\u003eLink\u003c/a\u003e\n```\n\nWhen a link with the `data-method` attribute is clicked, a form is dynamically created based on the link's attributes.\n\n- The `action` attribute of the form is set to the `href` value of the link.\n- The `method` attribute of the form is set to `post` (a fixed value).\n\nAdditionally, the HTTP method specified in the `data-method` attribute is included in a hidden input field with the name `_method`.\nThis follows Ruby on Rails' convention, where all HTTP methods other than GET and POST are sent via POST, with the actual method specified using the `_method` parameter.\n\nThe generated HTML form looks like this:\n\n```html\n\u003c!-- \u003ca href=\"/path\" data-method=\"post\"\u003eLink\u003c/a\u003e --\u003e\n\n\u003cform action=\"/path\" method=\"post\" style=\"display: none;\"\u003e\n  \u003cinput name=\"_method\" value=\"post\" type=\"hidden\"\u003e\n  \u003cinput type=\"submit\"\u003e\n\u003c/form\u003e\n```\n\n### Disable Form\n\nTo prevent double submission after submitting the form, the submit button will be disabled.\n\n- When the form is submitted, the `disabled` attribute is added to the submit button.\n- When navigating back in the browser, the `disabled` attribute is removed from the submit button that had been disabled.\n\n\n## Development\n\nAfter checking out the repo, run `npm install` to install dependencies. Then, run `npm test` to run the tests.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/taketo1113/alt-ujs.\n\n## License\n\nThis npm package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaketo1113%2Falt-ujs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaketo1113%2Falt-ujs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaketo1113%2Falt-ujs/lists"}