ncri / nested_form_fields

Dynamically add and remove nested has_many association fields in a Ruby on Rails form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gem doesn't work with rails-ujs

psmir opened this issue · comments

commented

When I use rails-ujs instead of jquery_ujs and try to remove nested fields by remove_nested_fields_link, I get the following error:
TypeError: $.rails.allowAction is not a function

Check this issue here: #92 Possibly you can define $.rails.allowAction somewhere and make it return true as a hack. But haven't tried.

Add gem 'jquery-rails' in your Gemfile.
In your application.js remove //= require rails-ujs and add //= require jquery_ujs. This worked for me in rails 5.2.2

I defined $.rails.allowAction = function() { return true } and it fixed the issue when migrating to Rails UJS.