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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:11:43+00:00 2026-05-28T03:11:43+00:00

I have a page where it allows users to add new ul dynamically using

  • 0

I have a page where it allows users to add new ul dynamically using jQuery, which I took this as reference: http://railscasts.com/episodes/197-nested-model-form-part-2?view=asciicast

I used this to add the new ul dynamically:

function add_fields(link, association, content) {
  var new_id = new Date().getTime();
  var regexp = new RegExp("new_" + association, "g");
  $(link).parent().before(content.replace(regexp, new_id));
}

Now I am extending it to make it sortable with the following:

  $(document).ready(function () {
    $(".sortable_list").sortable({
      items: "li"
    }).disableSelection();
  });

The problem over here now is that for existing content, there is a class ui-sortable in the ul appended when the page loads, so the jQuery only remembers these ul as sortable. When I add a new ul dynamically, the ui-sortable class is not appended, thus it is not sortable.

I tried hardcoding my template to include a class ui-sortable on each new ul whenever it is added dynamically, but jQuery still doesn’t recognize the new ul with ui-sortable as sortable.

Correct me if I am wrong. I am suspecting that jQuery only finds all lists that are in ul.sortable_list as sortable when it first loads. That’s it. For each newly added ul.sortable_list, it won’t be sortable.

Please advise how can I fix this. Thanks!

  • 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-05-28T03:11:43+00:00Added an answer on May 28, 2026 at 3:11 am

    I read it,Use this easy way.It may will work possibly.

    function add_fields(link, association, content) {
      var new_id = new Date().getTime();
      var regexp = new RegExp("new_" + association, "g");
      $(link).parent().before(content.replace(regexp, new_id));
    
      $(".sortable_list").sortable({
        items: "li"
      }).disableSelection();     
    
    }
    

    Note : Make sure that your sortable code execute work.I run this code one year age and it work for me great.I hope it work for you same as me

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

Sidebar

Related Questions

I have a page that has fields dynamically loaded via JQuery. It allows a
I have a web page which allows the user to carry out various operations
I have a page which basically allows an admin user to create manager user
I have a MVC page which allows creation and editing of a subcontract. When
I have a ASP.NET page which allows an administrator to change the password for
I am using jquery to add mulitple new addTask form elements to a ul
I have an ASPX page (On server A) which is invoked using NTLM credentials.
I have a web page that allows users to insert form input objects with
I'm developing a web page in Asp.Net 1.1 and have a DataGrid which allows
I'm using ASP.Net/C# and I have a form that allows people to add information

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.