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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With