select2_simple_form icon indicating copy to clipboard operation
select2_simple_form copied to clipboard

select2_simple_form and cocoon gem

Open jsperezg opened this issue 8 years ago • 0 comments

Good morning.

I'm using select2_simple_form in combination with cocoon in order to deal with nested models. The problem that I've foud is that each time a new nested record is added select2 inputs for this row do now correctly initializes the select2 inputs. I'm trying with this code, but without much success:

$("form").on("cocoon:after-insert", function(_, row) {
    var select = row.find('.place_scheduled_tasks_chemical_product_ids').find('select');
    if (select.length) {
      Select2SimpleForm.init({allow_html: true}, select);
    }
  });

How can I use the Select2SimpleForm class in order to initialize input added dynamically to a form? Is there a place where I can find any documentation regarding to it?

jsperezg avatar Feb 22 '18 08:02 jsperezg