Skip to content

select2_simple_form and cocoon gem #14

@jsperezg

Description

@jsperezg

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions