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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:41:25+00:00 2026-05-26T03:41:25+00:00

OK, so I am sorting a group of dashboard widgets with jQuery UI and

  • 0

OK, so I am sorting a group of dashboard widgets with jQuery UI and would like to retain the new order of the widgets. What is the best approach to this? Any ideas?

I was thinking of giving an attribute of “order” within the model like so:

widgetsModel: Backbone.Model.extend({
    defaults: {
        name: 'Widget',
        category: 'uncategorized',
        order: '0',
        content: 'No Content'

    },

    initialize: function(i) {
        this.bind("change:name", function() {
            var name = this.get("name");
            console.log('From Model: '+name);
        });

        this.bind('error', function(model, error) {
            alert(error);
        });

    }

})

Then within the collection I have this:

widgetsCollection: Backbone.Collection.extend({

    model: mw.models.widgetsModel,

    localStorage: new Store('widgets_'+mw.mainTab),

    initialize: function(widget){

        var $this = this;

        _.bind('add', function(widget){
            //console.log(widget.get('name'));
        });

        $('#dash_widget_container').sortable({
            items:'.module_wrap',
            accepts:'.module_wrap',
            handle: '.module_header',
            tolerance: 'pointer',
            revert:true,
            placeholder: "ui-state-highlight"
        });


    },

    nextOrder: function() {
        if (!this.length) return 1;
        return this.last().get('order') + 1;
    },

    comparator: function(widgets) {
        return widgets.get('order');
    }

})

At this point I am stuck. Any ideas out there?

  • 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-26T03:41:25+00:00Added an answer on May 26, 2026 at 3:41 am

    How about reseting the WidgetsCollection and then putting the WidgetModels back in the new order.

    console.log(widgetsCollection.models) // => model1, model2, model3
    widgetsCollection.reset([model2, model3, model1]);
    console.log(widgetsCollection.models) // => model2, model3, model1
    

    You can use JQuery UI to get the new order. That way they’re saved in order and there’s no extra overhead.

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

Sidebar

Related Questions

Which sorting algorithm would you choose if you would be in a group of
an example would be... Pets.find(:all, :select => 'count(*) count, pet_type', :group => 'pet_type', :order
I would like to sort through a table (Lessons) and group them by Subject(A
I using jquery sorting ( http://jqueryui.com/demos/sortable/ ). Is it possible to sort (move list)
I am using JS sorting to call this method: def sort params[:piece].each_with_index do |id,
I'm sorting a NSMutableArray that has NSString that contain numbers. This is the code
Here is a simple sorting program of an ArrayList: ArrayList<String> list = new ArrayList<String>();
I'd like to group elements by the first letter, but some different letters should
select p.Id, sum(inc.Quantity) from Products p join Incomes inc group by p.Id order by
In c# is there a structure like c++ map? I have a group of

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.