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 8613035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:46:24+00:00 2026-06-12T04:46:24+00:00

I currently have an input form generated using Cocoon and would like to make

  • 0

I currently have an input form generated using Cocoon and would like to make the input fields created by it sortable (using sortable from jQuery-ui).

The code for the nested form is:

<%= f.simple_fields_for :checkout_procedures do |procedure| %>  
  <li><%= render 'checkout_procedure_fields', :f => procedure %></li> 
<% end %>  
<div class="links">
  <%= link_to_add_association 'add step', f, :checkout_procedures %>
</div>

The partial that is rendered (_checkout_procedure_fields) is:

<div class="checkout_procedure nested-fields">
  <table>
    <tr>
      <td><%= f.input :step %></td>
      <td><%= link_to_remove_association "remove step", f %></td>
    </tr>
  </table>
</div>

I am able to get the existing elements sortable by putting them inside of a <div> and setting it sortable using jQuery:

<div class="sortThese">
   <%= f.simple_fields_for :checkout_procedures do |procedure| %>  
     <li><%= render 'checkout_procedure_fields', :f => procedure %></li> 
   <% end %>  
</div> 
<div class="links">
  <%= link_to_add_association 'add step', f, :checkout_procedures %>
</div>

<script>
 $(document).ready(function() {
   $(".sortThese").sortable();
      });
 </script>

But doing this breaks the functionality of Cocoon’s link_to_add_association and link_to_remove_association. Using <ul> with <li> also results in the same Cocoon malfunction. I’ve been looking around to hack some javascript that moves each input form in and out of the sortable div (doing this seems to make the links work again), but obviously this is inelegant. If anybody has any suggestions, I’d really appreciate them!

  • 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-12T04:46:25+00:00Added an answer on June 12, 2026 at 4:46 am

    It sorts well, if you remove <li> tag. Tried in my project, where i have the same markup, except li wrapper of partial, and it works.

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

Sidebar

Related Questions

I have a dynamically generated form with input fields with the same name (for
Currently I have two pages: The first page contains an input form, and the
I have a question. Currently this form will be dynamically generated. Example, <form method=POST>
I have a Date Input text box generated by jquery Date Picker which is
I'm using the jQuery validation plugin to validate a form. The form fields are
I currently have an asp form that uses jquery for two elements: an image
I have the following dynamically generated HTML <div id=1> <form name = inpForm> <input
I currently have a form with inputs and name attributes. I'm able to get
Currently I have Input: e.g., '123456789'.'+'.'987654321' Desired Pattern: Output: e.g., '123456789987654321' How can I
I currently have a series links that open menus containing dropdowns and input textboxes

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.