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

Functions on fields-added get executed twice

robbevp opened this issue · comments

I can't seem to figure out why, but function that wait on fields-added seem to be executed twice

So

$(document).on("fields_added.nested_form_fields", function(){
  console.log("hi")
});

gives two times hi in the console

# file.js
var i = 0
$(document).on("fields_added.nested_form_fields", function(){
  i += 1
  console.log(i)
});

results in

# console
1 file.js:44:11
2 file.js:44:11

Any suggestions on what could cause this?