edtior: fix exercise.order document events handling
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 7 Aug 2014 14:44:44 +0000 (16:44 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 14 Aug 2014 14:26:15 +0000 (16:26 +0200)
src/editor/plugins/core/edumed/order/element.js

index a81155e..724f2ec 100644 (file)
@@ -57,7 +57,7 @@ _.extend(OrderExerciceElement, {
         this.createContainer(this.wlxmlNode.object.getDescription(), {
             resetBackground: true,
             manages: function(node, removedFrom) {
-                if(node.is('list.orderable')) {
+                if(node.is('list.orderable') || (removedFrom && removedFrom.is('list.orderable'))) {
                     return false;
                 }
                 return exerciseNode.sameNode(node.parent() || removedFrom); //!n.hasFollowingSibing(this.params.listnode);    
@@ -79,6 +79,12 @@ _.extend(OrderExerciceElement, {
             this.reloadView();
         }
     },
+    onNodeDetached: function(event) {
+        var node = event.meta.node;
+        if(node.is('item.answer') && event.meta.parent && event.meta.parent.is('list.orderable')) {
+            this.reloadView();
+        }
+    },
     reloadView: function() {
         this.view.clearItems();
         this.wlxmlNode.object.getItems().forEach(function(item) {