{"id":21919388,"url":"https://github.com/existentialmutt/ajax_modal_rails","last_synced_at":"2025-07-16T05:15:08.698Z","repository":{"id":62553121,"uuid":"104930252","full_name":"existentialmutt/ajax_modal_rails","owner":"existentialmutt","description":"ajax-driven modals for rails apps using bootstrap 4","archived":false,"fork":false,"pushed_at":"2020-10-08T21:32:20.000Z","size":613,"stargazers_count":1,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-15T14:07:35.597Z","etag":null,"topics":["modals","rails"],"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/existentialmutt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-26T19:43:21.000Z","updated_at":"2021-07-18T20:21:00.000Z","dependencies_parsed_at":"2022-11-03T04:15:24.242Z","dependency_job_id":null,"html_url":"https://github.com/existentialmutt/ajax_modal_rails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/existentialmutt/ajax_modal_rails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existentialmutt%2Fajax_modal_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existentialmutt%2Fajax_modal_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existentialmutt%2Fajax_modal_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existentialmutt%2Fajax_modal_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/existentialmutt","download_url":"https://codeload.github.com/existentialmutt/ajax_modal_rails/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existentialmutt%2Fajax_modal_rails/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483897,"owners_count":23774292,"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":["modals","rails"],"created_at":"2024-11-28T20:06:57.860Z","updated_at":"2025-07-16T05:15:08.660Z","avatar_url":"https://github.com/existentialmutt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AjaxModalRails\n[![Build Status](https://travis-ci.org/existentialmutt/ajax_modal_rails.svg?branch=master)](https://travis-ci.org/existentialmutt/ajax_modal_rails)\n\nThis plugin provides a simple way to do common modal interactions in a rails app.  Keep your nice thin scaffolded controller, and just include a single mixin.  Then add data attribute to links and forms to load pages via ajax in a modal.\n\n![demo screencast](doc/demo.gif)\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'ajax_modal_rails', '~\u003e 1.0'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\n### Setup Layout and Javascript\nRun `rails generate ajax_modal_rails:install` to require the necessary javascript in `application.js` and add a partial render to the bottom of the body in `layouts/application.html.erb|haml`\n\n#### Manual Installation\n\nAdd `//= require ajax_modal_rails` to `app/assets/application.js`\n\nA page that opens a modal should call `render 'ajax_modal_rails/frame'` somewhere on the page.  We recommend you do this in your layout so the modal frame is available for all pages.\n\n## Usage\n\nOnce everything is set up, loading to modals is pretty simple\n\n### Views\n\nAdd the attribute `data-loads-in-ajax-modal` to a link and it's request will load in a modal over the current page.\n\nAdd the attribute `data-submits-to-ajax-modal` to a form and the response from the form's submit will load in the modal frame.\n\n### Controller\n\nA controller that is processing actions to be loaded in a modal should `include AjaxModalRails::Controller`\n\nThe mixin sets the appropriate layout for modal requests and adds behavior that allows a modal request that results in a redirect to redirect the whole page.\n\nNote that a controller that includes the `AjaxModalRails::Controller` module will have a few things done to it, including overriding the default implementation of `redirect_to` and also have it's default `layout` set.   These modifications should be pretty innocuous as they only take effect for ajax modal requests and fall back to the default behavior otherwise, but if you encounter unexpected behavior be sure to examine the code in [app/controllers/ajax_modal_rails/controller.rb](app/controllers/ajax_modal_rails/controller.rb) You can then either copy the file into your own repository and make modifications there or just add appropriate code to your including controllers.\n\n## Example\n\nThese snippets are taken from the included [example application](spec/dummy)\n\n*app/controllers/messages_controller.rb*\n```ruby\nclass MessagesController \u003c ApplicationController\n  before_action :set_message, only: [:edit, :update, :destroy]\n\n  include AjaxModalRails::Controller\n  ...\n```\n\n*app/views/messages/index.html.erb*\n```erb\n\u003c%= link_to 'New Message', new_message_path, data: {loads_in_ajax_modal: true} %\u003e\n```\n\n*app/views/messages/\\_form.html.erb*\n```erb\n\u003c%= form_with(model: message, data: {submits_to_ajax_modal: true}) do |form| %\u003e\n```\n\n## Customization\n\nIf you want to customize the behavior of this gem, run `rails generate ajax_modal_rails:customize`.  It will copy the views, javascript, and controller mixin into your application.\n\n## Requirements\n\nThe provided modal views and javascript require [Twitter Bootstrap 4.0](https://getbootstrap.com/docs/4.0/getting-started/introduction/).  You can do some customization if your app is using something else (see above).\n\n## License\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Gratitude\nThis gem was made possible by a Professional Development benefit from my employer, [Green River](http://www.greenriver.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexistentialmutt%2Fajax_modal_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexistentialmutt%2Fajax_modal_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexistentialmutt%2Fajax_modal_rails/lists"}