简体   繁体   中英

EmberJS + jqueryUI + sortable

I wanted to create a list (or table) with some sortable items in emberjs and jqueryui.

I uploaded a sample on JSFiddle: http://jsfiddle.net/KCxxu/

When I start it and click remove it works perfect. But when I first reorder the items and click remove again nothing happens till I click both delete buttons.

Any ideas?

Thanks a lot!

in your del function add contentWillChange() and contentDidChange()

Seems to work now

window.App = Ember.Application.create({});

Item = Ember.Object.extend({
    id : null,
    name : null
});

App.listController = Ember.ArrayProxy.create({
    content : [
        Item.create({id: 1, name : 'test'}),
        Item.create({id: 1, name : 'test2'}),
    ],
});

App.ListView = Ember.View.extend({
    tagName : 'tr',

    didInsertElement : function() {
        var me = this;
        this._super();

        // Make list sortable
        this.$().parent("tbody").sortable({
            items : 'tr',
            opacity : 0.6,
            axis : 'y'
        });
    },

    del : function(event) {
        var item = event.context;
        App.listController.contentWillChange();
        App.listController.removeObject(item);
        App.listController.contentDidChange();
    }
});

http://jsfiddle.net/KCxxu/3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM