Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:10:33+00:00 2026-06-18T12:10:33+00:00

I have a nested form using Cocoon. Within the nested form I have a

  • 0

I have a nested form using Cocoon. Within the nested form I have a select menu that I want to call chosen() on.

Normally I would have the following in the code

$('#cust_select').chosen()

However, I need to call this after a nested field has been added using something such as

    $('#container').bind('cocoon:before-insert', function(e, inserted_item) {
      // ... do something
    });

However, I can’t get this to work and so have 2 questions

  1. what is the coffee script version of this code?
  2. is inserted_item the actual code to use or should item be replaced with the model name?

any thoughts?

Michael

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:10:34+00:00Added an answer on June 18, 2026 at 12:10 pm

    1) The CoffeeScript version is:

    $('#cust_select').chosen() # just the same
    
    $('#container').bind 'cocoon:before-insert', (e, inserted_item) -> 
      # ... do something with the inserted item
    

    2) inserted_item is indeed the inserted item:

    From here

    To listen to the events, you to have the following code in your javascript:

    $('#container').bind('cocoon:before-insert', function(e, inserted_item) {
       // ... do something
    });
    

    Where e is the event and the second parameter is the inserted or removed item. This allows you to change markup, or add effects/animations (see example below).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a dynamically nested form using the cocoon gem. I have
I have a Rails nested form with the child fields that contain dynamic select
I currently have an input form generated using Cocoon and would like to make
I want to scrape some html pages that have nested form elements with lxml.
I have a nested form in a Rails 3.1 app, using Cocoon gem. In
I have a nested form in my app that uses AJAX to load an
I have nested list of the following form: my_list = [['Some1', '2', '3.6', '4.5',
I have a nested json. I want to post it as a form input
I have the following form for photo_album which uses the nested forms feature of
I have a simple nested form using the 'nested_form' gem. It looks like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.