No release in over a year
Since rails 7 uses HotWire, it became a bit hard to implement ajax submissions on form; This gem implements a vanilla js solution for it(just call it at the very end of your erb file and add the class ajaxForm to your form_with)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 7.0, >= 7.0.4.3
 Project Readme

SimpleAjaxForm

This gem was made in order to "bring back" the form_with remote: true(ajax) feature to rails 7;

Since it became a bit hard to use ajax with rails 7, this gem's intention is to make it "easy to use" the feature again

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add simple_ajax_form

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install simple_ajax_form

If you prefer to put by yourself on Gemfile and run command bundle install:

  gem 'simple_ajax_form', '~> 0.1.26'

Usage

Inside of your .erb file:

1 - Add ajaxForm to your form_with class

2 - Insert the request helper right after the form_with tag:

<%= form_with ... ,class: 'ajaxForm' do |f| >
<% end >

<%= SimpleAjaxForm::RequestHelper.enable_class_use_on_forms_html %>

Under the hood

This gem uses vanilla javascript with fetch to perform the request

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xitarps/simple_ajax_form.