Commit 9f211b8d authored by alexandre's avatar alexandre

Sortable seems to work!

parent d71cb34a
......@@ -70,15 +70,25 @@ window.W = window.W || {};
// console.log("relocated");
// console.log(this.model, index)
// }
'relocate': 'relocate',
'relocateChild': 'relocateChild'
},
triggers: {
'foobar': 'foobar'
// Triggered by jquery nested sortable when the item is
relocate: function(event, index) {
var parentItem = this.$el.parent().closest("li");
parentItem.trigger('relocateChild', [this.model, index]);
return false;
},
onFoobar: function(view, event) {
console.log(view.model);
console.log(view.model.get("parent"));
// Triggered by a subline view beeing relocated
relocateChild: function(event, model, index) {
model.get("parent").get("sublines").remove(model);
this.model.get("sublines").add(model, {at: index});
return false;
},
effaceAxe: function(e) {
......@@ -628,27 +638,6 @@ window.W = window.W || {};
return false;
},
// This event is triggered during sorting, but only when the DOM
// position has changed.
// onSortchange: function(view, event, ui) {
// console.log("changed")
// },
// onSortout: function(view, event, ui) {
// console.log("sorted out")
// },
// onSortupdate: function(view, event, ui) {
// console.log("updated")
// },
// onRelocate: function(view, event, ui) {
// console.log("relocated")
// console.log(view)
// console.log(event)
// console.log(ui)
// },
onSave: function(view, event) {
// console.log("ok");
this.model.save();
......@@ -673,33 +662,18 @@ window.W = window.W || {};
isAllowed: function(placeholder, placeholderParent, currentItem) {
return true;
},
start: function(e, ui) {
console.log("current index", ui.item.index());
console.log("current parent", $(ui.item).closest("li"))
},
update: function(e, ui) {
console.log("current index", ui.item.index());
console.log("current parent", $(ui.item).closest("li"))
},
// change: function(event, ui) {
// // console.log("***");
// console.log("change");
// // console.log(event);
// // console.log(ui);
// },
relocate: function(event, ui) {
ui.item.trigger('foobar');
// console.log(ui.item);
// console.log(firstRegion.$el.nestedSortable('toArray'));
// console.log(firstRegion.$el.nestedSortable('toHierarchy'));
// console.log("***");
// console.log("relocate");
// console.log(event);
// console.log(ui);
// ui.item.trigger('relocate', ui.item.index());
// console.log("<<<");
// console.log(ui.item.parentItem);
// console.log(">>>");
/*
* When the sort action is over:
* 1. trigger an event "relocate" on the item beeing sorted, along with its index
* 2. listen and catch event "relocate" on the view that is responsible for the item
* 3. trigger an event "relocateChild" on the parent element, along with the index, and the item model
* 4. listen and catch event "relocateChild" on the view that is responsible for the parent item
* 5. console.log that
* console.log("stop");
* ui.item.trigger("drop", ui.item.index());
*/
ui.item.trigger("relocate", ui.item.index());
},
});
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment