Gem doesn't work with Turbolinks
With Turbolinks present, clicking on add_nested link results in two sets of fields being created. I tried moving the load order around on the js, but that had no effect.
The gem works fine with turbolinks for us. It sounds like you have attached the event handlers twice? I remember someone had that issue here.
The problem I had seen was where the nested fields js was loaded twice in a page. I went through all of the loaded scripts on the page and only saw it once. Removing turbolinks fixed the problem, but is obviously not the most desirable solution. I'll take another deeper look and see if it is being called anywhere else that could produce that phenomenon.
On Fri, Nov 11, 2016 at 12:12 PM, Nico Ritsche [email protected] wrote:
The gem works fine with turbolinks for us. It sounds like you have attached the event handlers twice? I remember someone had that issue here.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ncri/nested_form_fields/issues/82#issuecomment-260045161, or mute the thread https://github.com/notifications/unsubscribe-auth/ABI5wRx-TusttmSgRZ7jR0NHw0vqhYTlks5q9MwcgaJpZM4KwFt- .
@jleecbd load "//=require nested_form_fields" before turbolinks on your application.js file
Agreed @jleecbd. This is the default setup I use for application.js now:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
// ... your other scripts here ...
//
//= require turbolinks
Note that you need to include the jquery turbolinks gem in your gemfile to have this manifest file be valid. The above setup is from their readme https://github.com/kossnocorp/jquery.turbolinks
Thanks for those tips