diff --git a/source/Ox.UI/js/List/List.js b/source/Ox.UI/js/List/List.js index 6da22297..458dcedd 100644 --- a/source/Ox.UI/js/List/List.js +++ b/source/Ox.UI/js/List/List.js @@ -86,6 +86,7 @@ Ox.List = function(options, self) { }) .options(options || {}) .update({ + draggable: updateDraggable, items: function() { if (!self.isAsync) { updateItems(); @@ -114,9 +115,8 @@ Ox.List = function(options, self) { selected: function() { setSelected(self.options.selected); }, - sort: function() { - updateSort(); - } + sort: updateSort, + sortable: updateSortable }) .scroll(scroll); @@ -154,22 +154,8 @@ Ox.List = function(options, self) { } }); - if (self.options.draggable) { - that.$content.bindEvent({ - dragstart: dragstart, - drag: drag, - dragpause: dragpause, - dragenter: dragenter, - dragleave: dragleave, - dragend: dragend - }); - } else if (self.options.sortable) { - that.$content.bindEvent({ - dragstart: movestart, - drag: move, - dragend: moveend - }); - } + self.options.draggable && updateDraggable(); + self.options.sortable && updateSortable(); // fixme: without this, horizontal lists don't get their full width self.options.orientation == 'horizontal' && that.$content.css({height: '1px'}); @@ -1360,6 +1346,17 @@ Ox.List = function(options, self) { unloadPage(page + 1) } + function updateDraggable() { + that.$content[self.options.draggable ? 'bindEvent' : 'unbindEvent']({ + dragstart: dragstart, + drag: drag, + dragpause: dragpause, + dragenter: dragenter, + dragleave: dragleave, + dragend: dragend + }); + } + function updateItems() { clear(); that.$content.empty(); @@ -1511,6 +1508,14 @@ Ox.List = function(options, self) { //} } + function updateSortable() { + that.$content[self.options.sortable ? 'bindEvent' : 'unbindEvent']({ + dragstart: movestart, + drag: move, + dragend: moveend + }); + } + /*@ addItems add item to list (pos, items) -> add items to list at position diff --git a/source/Ox.UI/js/List/TableList.js b/source/Ox.UI/js/List/TableList.js index 3c08bf2d..0f2cc519 100644 --- a/source/Ox.UI/js/List/TableList.js +++ b/source/Ox.UI/js/List/TableList.js @@ -90,6 +90,9 @@ Ox.TableList = function(options, self) { ? disableHorizontalScrolling() : enableHorizontalScrolling(); }, + draggable: function() { + that.$body.options({sortable: self.options.draggable}); + }, items: function() { that.$body.options({items: self.options.items}); }, @@ -107,6 +110,9 @@ Ox.TableList = function(options, self) { sort: function() { updateColumn(); that.$body.options({sort: self.options.sort}); + }, + sortable: function() { + that.$body.options({sortable: self.options.sortable}); } }) .addClass('OxTableList');