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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:43:55+00:00 2026-06-09T20:43:55+00:00

My web app has a feature where users can create a list of up

  • 0

My web app has a feature where users can create a list of up to five items. When a list is created, we automatically name it after the first item, though the user can also type a custom name. So, you’ll have something like this:

Name: [ Item 1 ] (this is a text box)

- Item 1
- Item 2
- Item 3
- Item 4
- Item 5

I’ve also set up jQuery UI’s sortable interaction so that users can click and drag to rearrange items in the list. Now, what I want to do is auto-rename the list after whatever the first item is once the user completes a drag, but only if they haven’t entered a custom name (which can be determined by comparing the name to the original first item and seeing if they match).

I know that sortable provides a number of events that you can use to run custom functions (like start and stop). The problem is that I need to run functions both before and after the drag happens in order to do the comparison, but (as far as I know) I can’t pass data between them – a variable defined in start can’t be used in stop. So how would I write this?

  • 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-09T20:43:56+00:00Added an answer on June 9, 2026 at 8:43 pm

    I solved this by saving the first item in a global variable on start, then using that to compare to the current title on stop. Maybe not the best way to do it, but it does work:

    var saveFirstItem = function(first_item) {
        startFirstItem = first_item;
    };
    
    $(document).ready(function(){
        $("#list").sortable({
            start: function(event, ui){
                var first_item = $("#list li:first-child").text();
                saveFirstItem(first_item);
            },
            stop: function(event, ui){      
                var first_item = $("#list li:first-child").text();      
                var current_title = $("#title").val();
    
                if (current_title == startFirstItem){
                    $("#title").val(first_item);
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a web app that has a built-in search feature that our users
Introduction Google chrome has a feature that allows you to create shortcuts to web
I have a web app (sencha/phonegap) that includes a feature allowing users to click
I use the mojolicious framework to write Web-App. Mojo::Base has a nice feature to
In a web app I am working on, the user can create a zip
I am trying to create my first web application using ASP.NET. I've created new
My web app has been chugging along just great in Production for years with
I have a web app that has a big and complex form (fields, checks,
I'm maintaining a web app that has performance problems. I want to record a
I have an existing web app that has a data layer and a bll

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.