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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:37:03+00:00 2026-05-25T16:37:03+00:00

I need to sort some rows after they’ve been inserted. What I’m doing now

  • 0

I need to sort some rows after they’ve been inserted. What I’m doing now is:

var $r = $tbody.find('tr').sort(function(a,b) { 
  return compare(taxstatusOf(a), taxstatusOf(b));
});
$tbody.empty().append($r);

This works, except that functions that were bound to elements contained in the rows are no longer bound (or no longer fire, which amounts to the same thing).

So, is there a right way to sort rows that doing fail like this? Do I have to re-bind?

  • 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-25T16:37:03+00:00Added an answer on May 25, 2026 at 4:37 pm

    D’oh.

    The right answer, sports fans, is .detach(). .remove() is supposed to strip the removed elements bare (removing local data and bound functions and such), which is great for garbage-collection and so forth but exactly what you don’t want when you’re planning to re-attach them later.

    The working code:

    var $r = $tbody.find('tr').sort(function(a,b) { 
      return compare(taxstatusOf(a), taxstatusOf(b));
    }).detach().appendTo($tbody);
    

    (I’m not going to “accept” my own answer for a little while in case someone comes up with a better one.)

    (I guess it’s good that I found the answer 30 seconds after posting the question. Now the next guy on SO will profit from my mistake.)

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

Sidebar

Related Questions

I have some sort of recursive function, but I need to parse a string,
I need some sort of interactive chart control for my .NET-based web app. I
I need some sort of node-graph editor, that hopefully works on both Mac and
To preface I am using Borland C++ and the VCL. I need some sort
We are starting a rather complex new project at work, and need some sort
I need to develop some sort of application featuring Editing Movie slices, Adding and
Is there some sort of built-in authentication in WCF? I need to expose a
I've written the following IComparer but I need some help. I'm trying to sort
I need to sort some data that is not coming from a database, but
I need to sort a field name of that contains some name, NULL and

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.