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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:04:54+00:00 2026-06-01T11:04:54+00:00

I have an Ember.js app that has a Checklist model, where each Checklist has

  • 0

I have an Ember.js app that has a Checklist model, where each Checklist has many Checkitems. (A variant of the classic ToDo app, but with multiple TodoLists.)

In the top-most view, the user sees a listing of all available checklists to the left. When a checklist is selected, the corresponding checkitems appear to the right.

The checkitems on the right side are drag sortable. I’m using this html5sortable library to handle drag sorting. It’s like the classic jQueryUI version, but less clunky.

Upon initial loading of the app, the sortable list works fine. However, if the list of checkitems changes (either because a checkitem is marked as complete, a new checkitem is added, changes to an existing check item are saved, or another checklist is selected on the left), the binding to html5sortable is lost.

When the app first loads, I have a view called App.CheckitemsPendingTableView:

App.CheckitemsPendingTableView = Ember.View.extend({
  templateName: 'app/templates/checkitems/checkitemsPendingTable',
  classNames: ['checkitems-list', 'sortable', 'list'],
  tagName: 'ul',

  didInsertElement: function() {
    this._super();
    $('ul.sortable').sortable();
    console.log('CheckitemsPendingTableView has been inserted in the DOM and is bound to sortable.  At this point, drag-sorting of the list is working fine.');
  }
});

The corresponding template is called checkitemsPendingTable.handlebars and it looks like this:

{{#each content}}
  {{view App.CheckitemSingleView checkitemBinding="this"}}
{{/each}}

And for good measure, the controller that feeds the content attribute for that view is App.checkitemsController.remainingItems:

App.checkitemsController = Ember.ArrayProxy.create({
  content:[],

  ...snip...

  remainingItems: function() {
    var checkitems = this.get('content');
    var sortedCheckitems = checkitems.filterProperty('isDone', false).sort(function(a,b) {
                            return a.get('position') - b.get('position');
                          });
    return sortedCheckitems;
  }.property('content.@each.isDone'),

  ...snip...

});

The content attribute of the checkitemsController is driven by the checklistsController:

App.checklistsController = Ember.ArrayProxy.create({
  content: App.store.findAll(App.Checklist),

  selectedChanged: function() {
    var checklist = this.get('selected');
    var checkitems = checklist.get('checkitems');
    App.checkitemsController.set('checklist', checklist);
    App.checkitemsController.set('content', checkitems);
  }.observes('selected')
});

(You may have noticed that this controller pulls its data from a Rails backend via ember-data. This shouldn’t matter for the current issue, though.)

The view for the left-hand side’s menu is called checklistsView. It has a child view called checklistSingleView that is rendered for each of the checklists:

App.ChecklistSingleView = Ember.View.extend({
  templateName: 'app/templates/checklists/checklistSingle',
  classNames:   ['menu-item'],
  tagName: 'tr',

  ...snip...

  chooseList: function() {
    var checklists = App.checklistsController.get('content');
    checklists.setEach('isActive', false);
    var checklist = this.get('checklist');
    checklist.set('isActive', true);
    App.checklistsController.set('selected', checklist);
  }

  ...snip...

});

And, finally, the corresponding template checklistSingle.handlebars contains a link that is tied to the chooseList by way of an action:

<a href="#" {{action "chooseList"}}>{{checklist.name}}</a>

So, everything above works brilliantly…until the user causes a change to the ul of checkitems on the right. At that point, the binding to html5sortable is lost, and I cannot find a convenient place to refresh it.

The problem is that didInsertElement is not called again for the view that generates that ul (i.e., CheckitemsPendingTableView). When the checklistController’s content attribute changes, the child views dutifully adjust to reflect the currently-selected list of checkitems. However, the original binding to sortable() is lost, and there is no apparent hook for re-binding to sortable() via jQuery.

I can’t re-bind on the child view of CheckitemsPendingTableView, since that would repeat for every instance of a checkitem in the currently-selected list. I can’t rebind from the controllers or models, since they will attempt to bind before the DOM update is completed.

I’m sure I’m just thinking about this incorrectly. I’m new to Ember.js (if it isn’t wildly obvious), and am struggling to understand how this case is properly handled.

UPDATE

I solved this problem, by adding the following function and observer to the App.CheckitemsPendingTableView:

resetSortableTable: function() {
    $('.sortable').unbind('sortable');
    $('.sortable').sortable();
    console.log('Sort reset by CheckitemsPendingTableView');
  },

itemsChanged: function() {
    console.log('itemsChanged caught in CheckitemsPendingTableView');
    // flush the RunLoop so changes are written to DOM
    Ember.run.sync();
    Ember.run.next(this, function() {
        this.resetSortableTable();
    });
  }.observes('content.@each')

I based my solution on this answer. I’m a little worried that it’s not a great solution, since it seems to be making assumptions about the DOM completing during a run loop iteration.

  • 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-01T11:04:55+00:00Added an answer on June 1, 2026 at 11:04 am

    Whoa! Kind of detailed question…

    I think your issue comes from html5sortable plugin: it uses JQuery’s bind method to attach handlers directly on living elements. As those elements disappear/evolve under Ember control, the binding are lost.

    The plugin should better use JQuery’s on method to bind handlers, as specified in the documentation.

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

Sidebar

Related Questions

I have a MongoMapper model called LogInfo that has a number of fields already
Say I have the following ember-data model: App.Person = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'),
What I have at the moment is a simple Facebook app that has pulled
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
So I have an object of ArrayProxy kind var App = Ember.Application.create(); App.car =
It is possible to have whitespace in an Ember.Object 's field name, but how
I have a hosted web application that has MongoDB as its DB. Now, I
I have a java application that will run on Windows 7 (using Swing, App
I've inherited an AS2 app that has a lot of functionality. I need to
I'm building an app that has a main Activity that takes advantage of the

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.