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

  • Home
  • SEARCH
  • 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 8403127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:15:40+00:00 2026-06-09T22:15:40+00:00

Possible Duplicate: Sortable and droppable knockout list I am using knockout to bind a

  • 0

Possible Duplicate:
Sortable and droppable knockout list

I am using knockout to bind a UL. I am wanting to gives users the ability to drag and drop a LI and for my viewmodel to update with the reorder.

Drag and drop is working and I have the correct event working within my jquery but I am not sure how to make the update.

I have had a hunt around the documentation but cant find anything.

I’ve created a fiddle to make explaining what I am doing a little easier

Js Fiddle here

Any suggestions would be awesome!

Updated the jsfiddle link

  • 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-09T22:15:42+00:00Added an answer on June 9, 2026 at 10:15 pm

    I’ve never worked with Knockout and I don’t have time to understand its intricacies right now, so this isn’t a complete solution, but here’s something to get you started. See below for links to some pages I found while searching that may help you complete the solution.

    This is the part that I changed from your original fiddle:

    var view_model = new ViewModel(initialData);
    
    ko.applyBindings(view_model);
    
    $(function() {
        $( "#sortable" ).sortable({
            revert: true,
            stop: function(event, ui) { console.log("stop event")},
    
    
            start : function ( event, ui ) {
    
                ui.item.data( 'previous_index', ui.item.index() );
    
            },
            // start
    
    
            update : function ( event, ui ) {
    
                var question = view_model.questions.splice(
    
                  ui.item.data( 'previous_index' ), 1
    
                )[0];
    
                view_model.questions.splice( ui.item.index(), 0, question );
    
                ui.item.removeData( 'previous_index' );
    
            }
            // update
    
        });
    });
    

    References:

    jQuery UI Sortable, how to determine current location and new location in update event?

    get the start position of an item using the jquery ui sortable plugin

    jQuery Sortable() with original position placeholder?

    knockout + jqueryui draggable/droppable follow-up

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

Sidebar

Related Questions

Possible Duplicate: Drag and Drop between Multiple Lists and Sortable I want to have
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: Python : how to append new elements in a list of list?
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?
Possible Duplicate: Unable to get a list of installed Python modules How do I
Possible Duplicate: Difference of create Index by using include column or not using Edit:
Possible Duplicate: Matlab gives wrong answer Can anyone explain to me why the following
Possible Duplicate: How do I make a list with checkboxes in Java Swing? I
Possible Duplicate: C# Sortable collection which allows duplicate keys Basically I'd like to make

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.